libalmath  2.1.4.13
 All Classes Namespaces Functions Variables Typedefs Groups Pages
alposition3d.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_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  };
287 
299  float distanceSquared(
300  const Position3D& pPos1,
301  const Position3D& pPos2);
302 
314  float distance(
315  const Position3D& pPos1,
316  const Position3D& pPos2);
317 
328  float norm(const Position3D& pPos);
329 
340  Position3D normalize(const Position3D& pPos);
341 
352  float dotProduct(
353  const Position3D& pPos1,
354  const Position3D& pPos2);
355 
368  Position3D crossProduct(
369  const Position3D& pPos1,
370  const Position3D& pPos2);
371 
382  void crossProduct(
383  const Position3D& pPos1,
384  const Position3D& pPos2,
385  Position3D& pRes);
386 
387  } // end namespace math
388 } // end namespace al
389 #endif // _LIBALMATH_ALMATH_TYPES_ALPOSITION3D_H_
Position3D operator*(float pVal) const
Overloading of operator * for Position3D.
Position3D & operator/=(float pVal)
Overloading of operator /= for Position3D.
Position3D normalize() const
Normalize the actual Position3D.
float norm() const
Compute the norm of the actual Position3D.
float dotProduct(const Position3D &pPos2) const
Compute the dot Product between the actual Position3D and the one give in argument.
bool operator==(const Position3D &pPos2) const
Overloading of operator == for Position3D.
float distanceSquared(const Position3D &pPos1, const Position3D &pPos2)
Compute the squared distance between two Position3D:
float norm(const Position3D &pPos)
Compute the norm of a Position3D:
bool operator!=(const Position3D &pPos2) const
Overloading of operator != for Position3D.
Position3D crossProduct(const Position3D &pPos2) const
Compute the cross Product between the actual Position3D and the one give in argument.
Position3D normalize(const Position3D &pPos)
Normalize a Position3D:
float crossProduct(const Position2D &pPos1, const Position2D &pPos2)
Compute the cross Product of two Position2D.
Position3D & operator+=(const Position3D &pPos2)
Overloading of operator += for Position3D.
Position3D()
Create a Position3D initialize with 0.0f.
Position3D operator-() const
Overloading of operator - for Position3D.
Definition: alposition3d.h:144
Position3D & operator-=(const Position3D &pPos2)
Overloading of operator -= for Position3D.
float distanceSquared(const Position3D &pPos2) const
Compute the squared distance between the actual Position3D and the one given in argument.
Create and play with a Position3D.
Definition: alposition3d.h:23
bool isNear(const Position3D &pPos2, const float &pEpsilon=0.0001f) const
Check if the actual Position3D is near the one give in argument.
Position3D operator+(void) const
Overloading of operator + for Position3D.
Definition: alposition3d.h:136
Position3D & operator*=(float pVal)
Overloading of operator *= for Position3D.
Position3D operator/(float pVal) const
Overloading of operator / for Position3D.
float distance(const Position3D &pPos2) const
Compute the distance between the actual Position3D and the one given in argument. ...
float distance(const Position3D &pPos1, const Position3D &pPos2)
Compute the distance between two Position3D: