Vector2d.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2016 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 
37  {
39  public: Vector2d();
40 
44  public: Vector2d(const double &_x, const double &_y);
45 
48  public: Vector2d(const Vector2d &_v);
49 
52  public: Vector2d(const ignition::math::Vector2d &_v);
53 
55  public: virtual ~Vector2d();
56 
60  public: double Distance(const Vector2d &_pt) const;
61 
63  public: void Normalize();
64 
68  public: void Set(double _x, double _y);
69 
73  public: double Dot(const Vector2d &_v) const;
74 
78  public: Vector2d &operator =(const Vector2d &_v);
79 
83  public: Vector2d &operator=(const ignition::math::Vector2d &_v);
84 
88  public: const Vector2d &operator =(double _v);
89 
93  public: Vector2d operator+(const Vector2d &_v) const;
94 
97  // \return this
98  public: const Vector2d &operator+=(const Vector2d &_v);
99 
103  public: Vector2d operator-(const Vector2d &_v) const;
104 
108  public: const Vector2d &operator-=(const Vector2d &_v);
109 
114  public: const Vector2d operator/(const Vector2d &_v) const;
115 
120  public: const Vector2d &operator/=(const Vector2d &_v);
121 
125  public: const Vector2d operator/(double _v) const;
126 
130  public: const Vector2d &operator/=(double _v);
131 
135  public: const Vector2d operator*(const Vector2d &_v) const;
136 
141  public: const Vector2d &operator*=(const Vector2d &_v);
142 
146  public: const Vector2d operator*(double _v) const;
147 
151  public: const Vector2d &operator*=(double _v);
152 
157  public: bool operator ==(const Vector2d &_v) const;
158 
161  public: bool operator!=(const Vector2d &_v) const;
162 
165  public: bool IsFinite() const;
166 
170  public: double operator[](unsigned int _index) const;
171 
174  public: ignition::math::Vector2d Ign() const;
175 
177  public: double x;
178 
180  public: double y;
181 
186  public: friend std::ostream &operator<<(std::ostream &_out,
187  const gazebo::math::Vector2d &_pt)
188  {
189  _out << _pt.x << " " << _pt.y;
190  return _out;
191  }
192 
197  public: friend std::istream &operator>>(std::istream &_in,
199  {
200  // Skip white spaces
201  _in.setf(std::ios_base::skipws);
202  _in >> _pt.x >> _pt.y;
203  return _in;
204  }
205  };
206 
208  }
209 }
210 #endif
211 
212 
213 
friend std::ostream & operator<<(std::ostream &_out, const gazebo::math::Vector2d &_pt)
Stream extraction operator.
Definition: Vector2d.hh:186
Generic double x, y vector.
Definition: Vector2d.hh:36
double y
y data
Definition: Vector2d.hh:180
#define GZ_MATH_VISIBLE
Definition: system.hh:134
double x
x data
Definition: Vector2d.hh:177
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:197