libalmath  2.5.11.14a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
alvelocity3d.h
Go to the documentation of this file.
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 
248  void writeToVector(std::vector<float>::iterator& pIt) const;
249  };
250 
251  Velocity3D operator* (
252  const float pM,
253  const Velocity3D& pVel1);
254 
265  float norm (const Velocity3D& pVel);
266 
277  Velocity3D normalize(const Velocity3D& pVel);
278 
279  } // end namespace Math
280 } // end namespace AL
281 #endif // _LIBALMATH_ALMATH_TYPES_ALVELOCITY3D_H_
Velocity3D & operator+=(const Velocity3D &pVel2)
Overloading of operator += for Velocity3D.
float norm(const Position2D &pPos)
Compute the norm of a Position2D.
bool isNear(const Velocity3D &pVel2, const float &pEpsilon=0.0001f) const
Check if the actual Velocity3D is Near the one given in argument.
Velocity3D & operator-=(const Velocity3D &pVel2)
Overloading of operator -= for Velocity3D.
Create and play with a Velocity3D.
Definition: alvelocity3d.h:23
std::vector< float > toVector(void) const
Velocity3D normalize() const
Normalize the actual Velocity3D:
Velocity3D operator-() const
Overloading of operator - for Velocity3D.
Definition: alvelocity3d.h:147
Velocity3D & operator*=(const float pVal)
Overloading of operator *= for Velocity3D.
void writeToVector(std::vector< float >::iterator &pIt) const
Write [xd, yd, zd] in the vector and update the iterator. It is assumed the vector has enough space...
Velocity3D & operator/=(const float pVal)
Overloading of operator /= for Velocity3D.
Position2D normalize(const Position2D &pPos)
Normalize a Position2D.
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()
Create a Velocity3D initialize with 0.0f.
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.
Position3D operator*(const Rotation &pRot, const Position3D &pPos)
Overloading of operator * between Rotation and Position3D:
Velocity3D operator*(const float pVal) const
Overloading of operator * for Velocity3D.
Definition: alvelocity3d.h:180