libalmath  2.8.7.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends 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 #include <almath/api.h>
14 
15 namespace AL {
16  namespace Math {
17 
24  struct ALMATH_API Position3D {
26  float x;
28  float y;
30  float z;
31 
34 
47  Position3D();
49 
52 
65  explicit Position3D(float pInit);
69 
72 
85  Position3D(
90  float pX,
91  float pY,
92  float pZ);
93 
96 
109  Position3D (const std::vector<float>& pFloats);
115 
120  inline Position3D operator+ (const Position3D& pPos2) const
121  {
122  return Position3D(x + pPos2.x, y + pPos2.y, z + pPos2.z);
123  }
124 
129  inline Position3D operator- (const Position3D& pPos2) const
130  {
131  return Position3D(x - pPos2.x, y - pPos2.y, z - pPos2.z);
132  }
133 
137  inline Position3D operator+ (void) const
138  {
139  return *this;
140  }
141 
145  inline Position3D operator- () const
146  {
147  return Position3D(-x, -y, -z);
148  }
149 
154  Position3D& operator+= (const Position3D& pPos2);
155 
160  Position3D& operator-= (const Position3D& pPos2);
161 
166  bool operator== (const Position3D& pPos2) const;
167 
172  bool operator!= (const Position3D& pPos2) const;
173 
178  Position3D operator* (float pVal) const;
179 
184  Position3D operator/ (float pVal) const;
185 
190  Position3D& operator*= (float pVal);
191 
196  Position3D& operator/= (float pVal);
197 
208  float distanceSquared(const Position3D& pPos2) const;
209 
220  float distance(const Position3D& pPos2) const;
221 
232  bool isNear(
233  const Position3D& pPos2,
234  const float& pEpsilon=0.0001f) const;
235 
244  float norm() const;
245 
254  Position3D normalize() const;
255 
266  float dotProduct(const Position3D& pPos2) const;
267 
280  Position3D crossProduct(const Position3D& pPos2) const;
281 
285  void toVector(std::vector<float>& pReturnVector) const;
286  std::vector<float> toVector(void) const;
287 
292  void writeToVector(std::vector<float>::iterator& pIt) const;
293 
302  bool isUnitVector(const float& pEpsilon=0.0001f) const;
303 
312  bool isOrthogonal(const Position3D& pPos, const float& pEpsilon=0.0001f) const;
313 
314  };
315 
327  ALMATH_API float distanceSquared(
328  const Position3D& pPos1,
329  const Position3D& pPos2);
330 
342  ALMATH_API float distance(
343  const Position3D& pPos1,
344  const Position3D& pPos2);
345 
356  ALMATH_API float norm(const Position3D& pPos);
357 
368  ALMATH_API Position3D normalize(const Position3D& pPos);
369 
380  ALMATH_API float dotProduct(
381  const Position3D& pPos1,
382  const Position3D& pPos2);
383 
396  ALMATH_API Position3D crossProduct(
397  const Position3D& pPos1,
398  const Position3D& pPos2);
399 
410  ALMATH_API void crossProduct(
411  const Position3D& pPos1,
412  const Position3D& pPos2,
413  Position3D& pRes);
414 
424  ALMATH_API bool isUnitVector(const Position3D& pPos,
425  const float& pEpsilon=0.0001f);
426 
437  ALMATH_API bool isOrthogonal(const Position3D& pPos1,
438  const Position3D& pPos2,
439  const float& pEpsilon=0.0001f);
440 
441  } // end namespace math
442 } // end namespace al
443 #endif // _LIBALMATH_ALMATH_TYPES_ALPOSITION3D_H_
ALMATH_API float distance(const Pose2D &pPos1, const Pose2D &pPos2)
Compute the distance between two Pose2D.
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
ALMATH_API bool isOrthogonal(const Position3D &pPos1, const Position3D &pPos2, const float &pEpsilon=0.0001f)
Checks if two Position3D are orthogonal
ALMATH_API float distanceSquared(const Pose2D &pPos1, const Pose2D &pPos2)
Compute the squared distance between two Pose2D.
bool operator!=(const Pose &lhs, const Pose &rhs)
Definition: urdf.h:340
ALMATH_API float crossProduct(const Position2D &pPos1, const Position2D &pPos2)
Compute the cross Product of two Position2D.
ALMATH_API float dotProduct(const Position2D &pPos1, const Position2D &pPos2)
Compute the dot Product between two Position2D:
ALMATH_API bool isUnitVector(const Position3D &pPos, const float &pEpsilon=0.0001f)
Checks if the norm of a Position3D is near to 1.0
ALMATH_API Position2D normalize(const Position2D &pPos)
Normalize a Position2D.
Create and play with a Position3D.
Definition: alposition3d.h:24
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: