All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Vector2d.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2014 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 /* Desc: Two dimensional vector
18  * Author: Nate Koenig
19  * Date: 3 Apr 2007
20  */
21 
22 #ifndef _VECTOR2D_HH_
23 #define _VECTOR2D_HH_
24 
25 #include <math.h>
26 #include <iostream>
27 #include <fstream>
28 #include "gazebo/util/system.hh"
29 
30 namespace gazebo
31 {
32  namespace math
33  {
36 
40  {
42  public: Vector2d();
43 
47  public: Vector2d(const double &_x, const double &_y);
48 
51  public: Vector2d(const Vector2d &_v);
52 
54  public: virtual ~Vector2d();
55 
59  public: double Distance(const Vector2d &_pt) const;
60 
62  public: void Normalize();
63 
67  public: void Set(double _x, double _y);
68 
72  public: Vector2d Cross(const Vector2d &_v) const;
73 
77  public: double Dot(const Vector2d &_v) const;
78 
82  public: Vector2d &operator =(const Vector2d &_v);
83 
87  public: const Vector2d &operator =(double _v);
88 
92  public: Vector2d operator+(const Vector2d &_v) const;
93 
96  // \return this
97  public: const Vector2d &operator+=(const Vector2d &_v);
98 
102  public: Vector2d operator-(const Vector2d &_v) const;
103 
107  public: const Vector2d &operator-=(const Vector2d &_v);
108 
113  public: const Vector2d operator/(const Vector2d &_v) const;
114 
119  public: const Vector2d &operator/=(const Vector2d &_v);
120 
124  public: const Vector2d operator/(double _v) const;
125 
129  public: const Vector2d &operator/=(double _v);
130 
134  public: const Vector2d operator*(const Vector2d &_v) const;
135 
140  public: const Vector2d &operator*=(const Vector2d &_v);
141 
145  public: const Vector2d operator*(double _v) const;
146 
150  public: const Vector2d &operator*=(double _v);
151 
156  public: bool operator ==(const Vector2d &_v) const;
157 
160  public: bool operator!=(const Vector2d &_v) const;
161 
164  public: bool IsFinite() const;
165 
169  public: double operator[](unsigned int _index) const;
170 
172  public: double x;
173 
175  public: double y;
176 
181  public: friend std::ostream &operator<<(std::ostream &_out,
182  const gazebo::math::Vector2d &_pt)
183  {
184  _out << _pt.x << " " << _pt.y;
185  return _out;
186  }
187 
192  public: friend std::istream &operator>>(std::istream &_in,
194  {
195  // Skip white spaces
196  _in.setf(std::ios_base::skipws);
197  _in >> _pt.x >> _pt.y;
198  return _in;
199  }
200  };
201 
203  }
204 }
205 #endif
206 
207 
208 
friend std::ostream & operator<<(std::ostream &_out, const gazebo::math::Vector2d &_pt)
Stream extraction operator.
Definition: Vector2d.hh:181
Generic double x, y vector.
Definition: Vector2d.hh:39
double y
y data
Definition: Vector2d.hh:175
double x
x data
Definition: Vector2d.hh:172
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:192
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48