libalmath  2.4.3.28-r2
 All Classes Namespaces Files Functions Variables Typedefs Macros Groups Pages
alposition3d.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_ALPOSITION3D_H_
10 #define _LIBALMATH_ALMATH_TYPES_ALPOSITION3D_H_
11 
12 #include <vector>
13 
14 namespace AL {
15  namespace Math {
16 
23  struct Position3D {
25  float x;
27  float y;
29  float z;
30 
33 
46  Position3D();
48 
51 
64  explicit Position3D(float pInit);
68 
71 
84  Position3D(
89  float pX,
90  float pY,
91  float pZ);
92 
95 
108  Position3D (const std::vector<float>& pFloats);
114 
119  inline Position3D operator+ (const Position3D& pPos2) const
120  {
121  return Position3D(x + pPos2.x, y + pPos2.y, z + pPos2.z);
122  }
123 
128  inline Position3D operator- (const Position3D& pPos2) const
129  {
130  return Position3D(x - pPos2.x, y - pPos2.y, z - pPos2.z);
131  }
132 
136  inline Position3D operator+ (void) const
137  {
138  return *this;
139  }
140 
144  inline Position3D operator- () const
145  {
146  return Position3D(-x, -y, -z);
147  }
148 
153  Position3D& operator+= (const Position3D& pPos2);
154 
159  Position3D& operator-= (const Position3D& pPos2);
160 
165  bool operator== (const Position3D& pPos2) const;
166 
171  bool operator!= (const Position3D& pPos2) const;
172 
177  Position3D operator* (float pVal) const;
178 
183  Position3D operator/ (float pVal) const;
184 
189  Position3D& operator*= (float pVal);
190 
195  Position3D& operator/= (float pVal);
196 
207  float distanceSquared(const Position3D& pPos2) const;
208 
219  float distance(const Position3D& pPos2) const;
220 
231  bool isNear(
232  const Position3D& pPos2,
233  const float& pEpsilon=0.0001f) const;
234 
243  float norm() const;
244 
253  Position3D normalize() const;
254 
265  float dotProduct(const Position3D& pPos2) const;
266 
279  Position3D crossProduct(const Position3D& pPos2) const;
280 
284  void toVector(std::vector<float>& pReturnVector) const;
285  std::vector<float> toVector(void) const;
286 
291  void writeToVector(std::vector<float>::iterator& pIt) const;
292 
301  bool isUnitVector(const float& pEpsilon=0.0001f) const;
302 
311  bool isOrthogonal(const Position3D& pPos, const float& pEpsilon=0.0001f) const;
312 
313  };
314 
326  float distanceSquared(
327  const Position3D& pPos1,
328  const Position3D& pPos2);
329 
341  float distance(
342  const Position3D& pPos1,
343  const Position3D& pPos2);
344 
355  float norm(const Position3D& pPos);
356 
367  Position3D normalize(const Position3D& pPos);
368 
379  float dotProduct(
380  const Position3D& pPos1,
381  const Position3D& pPos2);
382 
395  Position3D crossProduct(
396  const Position3D& pPos1,
397  const Position3D& pPos2);
398 
409  void crossProduct(
410  const Position3D& pPos1,
411  const Position3D& pPos2,
412  Position3D& pRes);
413 
423  bool isUnitVector(const Position3D& pPos,
424  const float& pEpsilon=0.0001f);
425 
436  bool isOrthogonal(const Position3D& pPos1,
437  const Position3D& pPos2,
438  const float& pEpsilon=0.0001f);
439 
440  } // end namespace math
441 } // end namespace al
442 #endif // _LIBALMATH_ALMATH_TYPES_ALPOSITION3D_H_
Position3D operator+(void) const
Overloading of operator + for Position3D.
Definition: alposition3d.h:136
Position3D operator-() const
Overloading of operator - for Position3D.
Definition: alposition3d.h:144
float crossProduct(const Position2D &pPos1, const Position2D &pPos2)
Compute the cross Product of two Position2D.
bool operator==(const Position3D &pPos2) const
Overloading of operator == for Position3D.
float norm(const Position2D &pPos)
Compute the norm of a Position2D.
Position3D & operator+=(const Position3D &pPos2)
Overloading of operator += for Position3D.
Position3D & operator-=(const Position3D &pPos2)
Overloading of operator -= for Position3D.
Position3D operator/(float pVal) const
Overloading of operator / for Position3D.
float norm() const
Compute the norm of the actual Position3D.
std::vector< float > toVector(void) const
Position3D & operator/=(float pVal)
Overloading of operator /= for Position3D.
Position3D & operator*=(float pVal)
Overloading of operator *= for Position3D.
bool isOrthogonal(const Position3D &pPos1, const Position3D &pPos2, const float &pEpsilon=0.0001f)
Checks if two Position3D are orthogonal
void writeToVector(std::vector< float >::iterator &pIt) const
Write [x, y, z] in the vector and update the iterator. It is assumed the vector has enough space...
float distanceSquared(const Pose2D &pPos1, const Pose2D &pPos2)
Compute the squared distance between two Pose2D.
Position3D operator*(float pVal) const
Overloading of operator * for Position3D.
float dotProduct(const Position2D &pPos1, const Position2D &pPos2)
Compute the dot Product between two Position2D:
bool operator!=(const Position3D &pPos2) const
Overloading of operator != for Position3D.
float distance(const Pose2D &pPos1, const Pose2D &pPos2)
Compute the distance between two Pose2D.
Position2D normalize(const Position2D &pPos)
Normalize a Position2D.
bool isUnitVector(const Position3D &pPos, const float &pEpsilon=0.0001f)
Checks if the norm of a Position3D is near to 1.0
Position3D crossProduct(const Position3D &pPos2) const
Compute the cross Product between the actual Position3D and the one give in argument.
Create and play with a Position3D.
Definition: alposition3d.h:23
bool isUnitVector(const float &pEpsilon=0.0001f) const
Checks if the norm of the Position3D is near to 1.0
float distanceSquared(const Position3D &pPos2) const
Compute the squared distance between the actual Position3D and the one given in argument.
Position3D normalize() const
Normalize the actual Position3D.
float dotProduct(const Position3D &pPos2) const
Compute the dot Product between the actual Position3D and the one give in argument.
bool isOrthogonal(const Position3D &pPos, const float &pEpsilon=0.0001f) const
Checks if this Position3D is orthogonal to Position3D pPos
Position3D()
Create a Position3D initialize with 0.0f.
bool isNear(const Position3D &pPos2, const float &pEpsilon=0.0001f) const
Check if the actual Position3D is near the one give in argument.
float distance(const Position3D &pPos2) const
Compute the distance between the actual Position3D and the one given in argument. ...