libalmath  2.8.7.4
 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 #include <almath/api.h>
14 
15 namespace AL {
16  namespace Math {
17 
24  struct ALMATH_API Velocity3D {
26  float xd;
28  float yd;
30  float zd;
31 
34 
47  Velocity3D();
49 
52 
65  explicit Velocity3D(float pInit);
69 
72 
85  Velocity3D(
90  float pXd,
91  float pYd,
92  float pZd);
93 
96 
109  Velocity3D(const std::vector<float>& pFloats);
115 
120  inline Velocity3D operator+ (const Velocity3D& pVel2) const
121  {
122  return Velocity3D(xd + pVel2.xd, yd + pVel2.yd, zd + pVel2.zd);
123  }
124 
129  inline Velocity3D operator- (const Velocity3D& pVel2) const
130  {
131  return Velocity3D(
132  xd - pVel2.xd,
133  yd - pVel2.yd,
134  zd - pVel2.zd);
135  }
136 
140  inline Velocity3D operator+ (void) const
141  {
142  return *this;
143  }
144 
148  inline Velocity3D operator- () const
149  {
150  return Velocity3D(-xd, -yd, -zd);
151  }
152 
157  Velocity3D& operator+= (const Velocity3D& pVel2);
158 
163  Velocity3D& operator-= (const Velocity3D& pVel2);
164 
169  bool operator== (const Velocity3D& pVel2) const;
170 
175  bool operator!= (const Velocity3D& pVel2) const;
176 
181  inline Velocity3D operator* (const float pVal) const
182  {
183  return Velocity3D(xd*pVal, yd*pVal, zd*pVal);
184  }
185 
190  Velocity3D operator/ (const float pVal) const;
191 
196  Velocity3D& operator*= (const float pVal);
197 
202  Velocity3D& operator/= (const float pVal);
203 
214  bool isNear(
215  const Velocity3D& pVel2,
216  const float& pEpsilon=0.0001f) const;
217 
218 
227  float norm () const;
228 
237  Velocity3D normalize() const;
238 
242  void toVector(std::vector<float>& pReturnValue) const;
243  std::vector<float> toVector(void) const;
244 
249  void writeToVector(std::vector<float>::iterator& pIt) const;
250  };
251 
252  ALMATH_API Velocity3D operator* (
253  const float pM,
254  const Velocity3D& pVel1);
255 
266  ALMATH_API float norm (const Velocity3D& pVel);
267 
278  ALMATH_API Velocity3D normalize(const Velocity3D& pVel);
279 
280  } // end namespace Math
281 } // end namespace AL
282 #endif // _LIBALMATH_ALMATH_TYPES_ALVELOCITY3D_H_
Create and play with a Velocity3D.
Definition: alvelocity3d.h:24
BodyMass< T > operator+(const BodyMass< T > &lhs, const BodyMass< T > &rhs)
Definition: bodymass.h:111
bool isNear(const Transform &lhs, const Transform &rhs, double epsilon)
Definition: qigeometry.h:111
bool operator!=(const Pose &lhs, const Pose &rhs)
Definition: urdf.h:340
ALMATH_API Position2D normalize(const Position2D &pPos)
Normalize a Position2D.
ALMATH_API float norm(const Position2D &pPos)
Compute the norm of a Position2D.
bool operator==(const BodyMass< T > &lhs, const BodyMass< T > &rhs)
Definition: bodymass.h:79
ALMATH_API Position3D operator*(const Rotation &pRot, const Position3D &pPos)
Overloading of operator * between Rotation and Position3D: