Vector3.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  * WITHOUT 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_MATH_VECTOR3_HH_
18 #define GAZEBO_MATH_VECTOR3_HH_
19 
20 #include <math.h>
21 #include <iostream>
22 #include <fstream>
23 #include <ignition/math/Vector3.hh>
24 
25 #include "gazebo/math/Helpers.hh"
26 #include "gazebo/util/system.hh"
27 
28 #ifndef _WIN32
29  #pragma GCC diagnostic push
30  #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
31 #endif
32 
33 namespace gazebo
34 {
35  namespace math
36  {
39 
44  class GZ_MATH_VISIBLE Vector3
45  {
47  public: static const Vector3 Zero;
48 
50  public: static const Vector3 One;
51 
53  public: static const Vector3 UnitX;
54 
56  public: static const Vector3 UnitY;
57 
59  public: static const Vector3 UnitZ;
60 
62  public: Vector3() GAZEBO_DEPRECATED(8.0);
63 
68  public: Vector3(const double &_x, const double &_y, const double &_z)
69  GAZEBO_DEPRECATED(8.0);
70 
73  public: Vector3(const ignition::math::Vector3d &_v)
74  GAZEBO_DEPRECATED(8.0);
75 
78  public: Vector3(const Vector3 &_v) GAZEBO_DEPRECATED(8.0);
79 
81  public: virtual ~Vector3() GAZEBO_DEPRECATED(8.0);
82 
85  public: double GetSum() const GAZEBO_DEPRECATED(8.0);
86 
90  public: double Distance(const Vector3 &_pt) const GAZEBO_DEPRECATED(8.0);
91 
97  public: double Distance(double _x, double _y, double _z) const
98  GAZEBO_DEPRECATED(8.0);
99 
102  public: double GetLength() const GAZEBO_DEPRECATED(8.0);
103 
106  public: double GetSquaredLength() const GAZEBO_DEPRECATED(8.0);
107 
110  public: Vector3 Normalize() GAZEBO_DEPRECATED(8.0);
111 
114  public: Vector3 Round() GAZEBO_DEPRECATED(8.0);
115 
118  public: Vector3 GetRounded() const GAZEBO_DEPRECATED(8.0);
119 
124  public: inline void Set(double _x = 0, double _y = 0 , double _z = 0)
125  GAZEBO_DEPRECATED(8.0)
126  {
127  this->x = _x;
128  this->y = _y;
129  this->z = _z;
130  }
131 
134  public: Vector3 Cross(const Vector3 &_pt) const GAZEBO_DEPRECATED(8.0);
135 
138  public: double Dot(const Vector3 &_pt) const GAZEBO_DEPRECATED(8.0);
139 
142  public: Vector3 GetAbs() const GAZEBO_DEPRECATED(8.0);
143 
146  public: Vector3 GetPerpendicular() const GAZEBO_DEPRECATED(8.0);
147 
153  public: static Vector3 GetNormal(const Vector3 &_v1, const Vector3 &_v2,
154  const Vector3 &_v3)
155  GAZEBO_DEPRECATED(8.0);
156 
161  public: double GetDistToLine(const Vector3 &_pt1, const Vector3 &_pt2)
162  GAZEBO_DEPRECATED(8.0);
163 
167  public: void SetToMax(const Vector3 &_v) GAZEBO_DEPRECATED(8.0);
168 
172  public: void SetToMin(const Vector3 &_v) GAZEBO_DEPRECATED(8.0);
173 
176  public: double GetMax() const GAZEBO_DEPRECATED(8.0);
177 
180  public: double GetMin() const GAZEBO_DEPRECATED(8.0);
181 
184  public: ignition::math::Vector3d Ign() const GAZEBO_DEPRECATED(8.0);
185 
189  public: Vector3 &operator=(const ignition::math::Vector3d &_v)
190  GAZEBO_DEPRECATED(8.0);
191 
195  public: Vector3 &operator =(const Vector3 &_v) GAZEBO_DEPRECATED(8.0);
196 
200  public: Vector3 &operator =(double _value) GAZEBO_DEPRECATED(8.0);
201 
205  public: Vector3 operator+(const Vector3 &_v) const GAZEBO_DEPRECATED(8.0);
206 
209  public: const Vector3 &operator+=(const Vector3 &_v)
210  GAZEBO_DEPRECATED(8.0);
211 
214  public: inline Vector3 operator-() const GAZEBO_DEPRECATED(8.0)
215  {
216  return Vector3(-this->x, -this->y, -this->z);
217  }
218 
222  public: inline Vector3 operator-(const Vector3 &_pt) const
223  GAZEBO_DEPRECATED(8.0)
224  {
225  return Vector3(this->x - _pt.x,
226  this->y - _pt.y,
227  this->z - _pt.z);
228  }
229 
232  public: const Vector3 &operator-=(const Vector3 &_pt)
233  GAZEBO_DEPRECATED(8.0);
234 
239  public: const Vector3 operator/(const Vector3 &_pt) const
240  GAZEBO_DEPRECATED(8.0);
241 
246  public: const Vector3 &operator/=(const Vector3 &_pt)
247  GAZEBO_DEPRECATED(8.0);
248 
252  public: const Vector3 operator/(double _v) const GAZEBO_DEPRECATED(8.0);
253 
257  public: const Vector3 &operator/=(double _v) GAZEBO_DEPRECATED(8.0);
258 
262  public: Vector3 operator*(const Vector3 &_p) const GAZEBO_DEPRECATED(8.0);
263 
268  public: const Vector3 &operator*=(const Vector3 &_v)
269  GAZEBO_DEPRECATED(8.0);
270 
275  public: friend inline Vector3 operator*(double _s,
276  const Vector3 &_v)
277  GAZEBO_DEPRECATED(8.0)
278  { return Vector3(_v.x * _s, _v.y * _s, _v.z * _s); }
279 
283  public: Vector3 operator*(double _v) const GAZEBO_DEPRECATED(8.0);
284 
288  public: const Vector3 &operator*=(double _v) GAZEBO_DEPRECATED(8.0);
289 
295  public: bool operator ==(const Vector3 &_pt) const;
296 
302  public: bool operator!=(const Vector3 &_v) const;
303 
305  public: bool IsFinite() const GAZEBO_DEPRECATED(8.0);
306 
308  public: inline void Correct() GAZEBO_DEPRECATED(8.0)
309  {
310  if (!std::isfinite(this->x))
311  this->x = 0;
312  if (!std::isfinite(this->y))
313  this->y = 0;
314  if (!std::isfinite(this->z))
315  this->z = 0;
316  }
317 
319  public: double operator[](unsigned int index) const
320  GAZEBO_DEPRECATED(8.0);
321 
324  public: void Round(int _precision) GAZEBO_DEPRECATED(8.0);
325 
330  public: bool Equal(const Vector3 &_v) const GAZEBO_DEPRECATED(8.0);
331 
333  public: double x;
334 
336  public: double y;
337 
339  public: double z;
340 
345  public: friend std::ostream &operator<<(std::ostream &_out,
346  const gazebo::math::Vector3 &_pt)
347  GAZEBO_DEPRECATED(8.0)
348  {
349  _out << precision(_pt.x, 6) << " " << precision(_pt.y, 6) << " "
350  << precision(_pt.z, 6);
351  return _out;
352  }
353 
358  public: friend std::istream &operator>>(std::istream &_in,
360  GAZEBO_DEPRECATED(8.0)
361  {
362  // Skip white spaces
363  _in.setf(std::ios_base::skipws);
364  _in >> _pt.x >> _pt.y >> _pt.z;
365  return _in;
366  }
367  };
369  }
370 }
371 #ifndef _WIN32
372  #pragma GCC diagnostic pop
373 #endif
374 #endif
double x
X location.
Definition: Vector3.hh:333
double y
Y location.
Definition: Vector3.hh:336
static const Vector3 UnitY
math::Vector3(0, 1, 0)
Definition: Vector3.hh:56
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:44
friend std::ostream & operator<<(std::ostream &_out, const gazebo::math::Vector3 &_pt) GAZEBO_DEPRECATED(8.0)
Stream insertion operator.
Definition: Vector3.hh:345
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 z
Z location.
Definition: Vector3.hh:339
static const Vector3 UnitZ
math::Vector3(0, 0, 1)
Definition: Vector3.hh:59
static const Vector3 One
math::Vector3(1, 1, 1)
Definition: Vector3.hh:50
GAZEBO_VISIBLE void Set(common::Image &_img, const msgs::Image &_msg)
Convert a msgs::Image to a common::Image.
friend Vector3 operator*(double _s, const Vector3 &_v) GAZEBO_DEPRECATED(8.0)
Multiplication operators.
Definition: Vector3.hh:275
friend std::istream & operator>>(std::istream &_in, gazebo::math::Vector3 &_pt) GAZEBO_DEPRECATED(8.0)
Stream extraction operator.
Definition: Vector3.hh:358
static const Vector3 UnitX
math::Vector3(1, 0, 0)
Definition: Vector3.hh:53
static const Vector3 Zero
math::Vector3(0, 0, 0)
Definition: Vector3.hh:47
Vector3 operator-(const Vector3 &_pt) const GAZEBO_DEPRECATED(8.0)
Subtraction operators.
Definition: Vector3.hh:222