libalmath  2.1.4.13
 All Classes Namespaces Functions Variables Typedefs Groups Pages
alvelocity3d.h
1 /*
2  * Copyright (c) 2012 Aldebaran Robotics. All rights reserved.
3  * Use of this source code is governed by a BSD-style license that can be
4  * found in the COPYING file.
5  */
6 
7 
8 #pragma once
9 #ifndef _LIBALMATH_ALMATH_TYPES_ALVELOCITY3D_H_
10 #define _LIBALMATH_ALMATH_TYPES_ALVELOCITY3D_H_
11 
12 #include <vector>
13 
14 namespace AL {
15  namespace Math {
16 
23  struct Velocity3D {
25  float xd;
27  float yd;
29  float zd;
30 
33 
46  Velocity3D();
48 
51 
64  explicit Velocity3D(float pInit);
68 
71 
84  Velocity3D(
89  float pXd,
90  float pYd,
91  float pZd);
92 
95 
108  Velocity3D(const std::vector<float>& pFloats);
114 
119  inline Velocity3D operator+ (const Velocity3D& pVel2) const
120  {
121  return Velocity3D(xd + pVel2.xd, yd + pVel2.yd, zd + pVel2.zd);
122  }
123 
128  inline Velocity3D operator- (const Velocity3D& pVel2) const
129  {
130  return Velocity3D(
131  xd - pVel2.xd,
132  yd - pVel2.yd,
133  zd - pVel2.zd);
134  }
135 
139  inline Velocity3D operator+ (void) const
140  {
141  return *this;
142  }
143 
147  inline Velocity3D operator- () const
148  {
149  return Velocity3D(-xd, -yd, -zd);
150  }
151 
156  Velocity3D& operator+= (const Velocity3D& pVel2);
157 
162  Velocity3D& operator-= (const Velocity3D& pVel2);
163 
168  bool operator== (const Velocity3D& pVel2) const;
169 
174  bool operator!= (const Velocity3D& pVel2) const;
175 
180  inline Velocity3D operator* (const float pVal) const
181  {
182  return Velocity3D(xd*pVal, yd*pVal, zd*pVal);
183  }
184 
189  Velocity3D operator/ (const float pVal) const;
190 
195  Velocity3D& operator*= (const float pVal);
196 
201  Velocity3D& operator/= (const float pVal);
202 
213  bool isNear(
214  const Velocity3D& pVel2,
215  const float& pEpsilon=0.0001f) const;
216 
217 
226  float norm () const;
227 
236  Velocity3D normalize() const;
237 
241  void toVector(std::vector<float>& pReturnValue) const;
242  std::vector<float> toVector(void) const;
243  };
244 
245  Velocity3D operator* (
246  const float pM,
247  const Velocity3D& pVel1);
248 
259  float norm (const Velocity3D& pVel);
260 
271  Velocity3D normalize(const Velocity3D& pVel);
272 
273  } // end namespace Math
274 } // end namespace AL
275 #endif // _LIBALMATH_ALMATH_TYPES_ALVELOCITY3D_H_
bool isNear(const Velocity3D &pVel2, const float &pEpsilon=0.0001f) const
Check if the actual Velocity3D is Near the one given in argument.
bool operator!=(const Velocity3D &pVel2) const
Overloading of operator != for Velocity3D.
Velocity3D operator+(void) const
Overloading of operator + for Velocity3D.
Definition: alvelocity3d.h:139
Velocity3D & operator-=(const Velocity3D &pVel2)
Overloading of operator -= for Velocity3D.
float norm(const Velocity3D &pVel)
Compute the norm of a Velocity3D:
Velocity3D operator-() const
Overloading of operator - for Velocity3D.
Definition: alvelocity3d.h:147
float norm() const
Compute the norm of the actual Velocity3D:
bool operator==(const Velocity3D &pVel2) const
Overloading of operator == for Velocity3D.
Velocity3D operator*(const float pVal) const
Overloading of operator * for Velocity3D.
Definition: alvelocity3d.h:180
Position3D operator*(const Rotation &pRot, const Position3D &pPos)
Overloading of operator * between Rotation and Position3D:
Velocity3D & operator*=(const float pVal)
Overloading of operator *= for Velocity3D.
Velocity3D & operator/=(const float pVal)
Overloading of operator /= for Velocity3D.
Velocity3D & operator+=(const Velocity3D &pVel2)
Overloading of operator += for Velocity3D.
Velocity3D operator/(const float pVal) const
Overloading of operator / for Velocity3D.
Velocity3D normalize(const Velocity3D &pVel)
Normalize a Velocity3D:
Create and play with a Velocity3D.
Definition: alvelocity3d.h:23
Velocity3D normalize() const
Normalize the actual Velocity3D:
Velocity3D()
Create a Velocity3D initialize with 0.0f.