Vector2d.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUdouble WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef _GAZEBO_VECTOR2D_HH_
18 #define _GAZEBO_VECTOR2D_HH_
19 
20 #include <ignition/math/Vector2.hh>
21 
22 #include <math.h>
23 #include <iostream>
24 #include <fstream>
25 #include "gazebo/util/system.hh"
26 
27 namespace gazebo
28 {
29  namespace math
30  {
33 
36  class GZ_MATH_VISIBLE Vector2d
37  {
39  public: Vector2d() GAZEBO_DEPRECATED(8.0);
40 
44  public: Vector2d(const double &_x, const double &_y)
45  GAZEBO_DEPRECATED(8.0);
46 
49  public: Vector2d(const Vector2d &_v) GAZEBO_DEPRECATED(8.0);
50 
53  public: Vector2d(const ignition::math::Vector2d &_v)
54  GAZEBO_DEPRECATED(8.0);
55 
57  public: virtual ~Vector2d();
58 
62  public: double Distance(const Vector2d &_pt) const;
63 
65  public: void Normalize();
66 
70  public: void Set(double _x, double _y);
71 
75  public: double Dot(const Vector2d &_v) const;
76 
80  public: Vector2d &operator =(const Vector2d &_v);
81 
85  public: Vector2d &operator=(const ignition::math::Vector2d &_v);
86 
90  public: const Vector2d &operator =(double _v);
91 
95  public: Vector2d operator+(const Vector2d &_v) const;
96 
99  // \return this
100  public: const Vector2d &operator+=(const Vector2d &_v);
101 
105  public: Vector2d operator-(const Vector2d &_v) const;
106 
110  public: const Vector2d &operator-=(const Vector2d &_v);
111 
116  public: const Vector2d operator/(const Vector2d &_v) const;
117 
122  public: const Vector2d &operator/=(const Vector2d &_v);
123 
127  public: const Vector2d operator/(double _v) const;
128 
132  public: const Vector2d &operator/=(double _v);
133 
137  public: const Vector2d operator*(const Vector2d &_v) const;
138 
143  public: const Vector2d &operator*=(const Vector2d &_v);
144 
148  public: const Vector2d operator*(double _v) const;
149 
153  public: const Vector2d &operator*=(double _v);
154 
159  public: bool operator ==(const Vector2d &_v) const;
160 
163  public: bool operator!=(const Vector2d &_v) const;
164 
167  public: bool IsFinite() const;
168 
172  public: double operator[](unsigned int _index) const;
173 
176  public: ignition::math::Vector2d Ign() const;
177 
179  public: double x;
180 
182  public: double y;
183 
188  public: friend std::ostream &operator<<(std::ostream &_out,
189  const gazebo::math::Vector2d &_pt)
190  {
191  _out << _pt.x << " " << _pt.y;
192  return _out;
193  }
194 
199  public: friend std::istream &operator>>(std::istream &_in,
201  {
202  // Skip white spaces
203  _in.setf(std::ios_base::skipws);
204  _in >> _pt.x >> _pt.y;
205  return _in;
206  }
207  };
209  }
210 }
211 #endif
212 
213 
214 
friend std::ostream & operator<<(std::ostream &_out, const gazebo::math::Vector2d &_pt)
Stream extraction operator.
Definition: Vector2d.hh:188
Forward declarations for the common classes.
Definition: Animation.hh:33
Generic double x, y vector.
Definition: Vector2d.hh:36
static const double GAZEBO_DEPRECATED(8.0) MAX_D
Double maximum value. This value will be similar to 1.79769e+308.
Definition: Helpers.hh:140
double y
y data
Definition: Vector2d.hh:182
double x
x data
Definition: Vector2d.hh:179
GAZEBO_VISIBLE void Set(common::Image &_img, const msgs::Image &_msg)
Convert a msgs::Image to a common::Image.
friend std::istream & operator>>(std::istream &_in, gazebo::math::Vector2d &_pt)
Stream extraction operator.
Definition: Vector2d.hh:199