libalmath  1.14
 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 
47  Position3D();
48 
51 
64 
65 
66 
67  explicit Position3D(float pInit);
68 
71 
84 
85 
86 
87 
88  Position3D(
89  float pX,
90  float pY,
91  float pZ);
92 
95 
108 
109 
110 
111 
112 
113  Position3D (const std::vector<float>& pFloats);
114 
119  Position3D operator+ (const Position3D& pPos2) const;
120 
125  Position3D operator- (const Position3D& pPos2) const;
126 
130  Position3D operator+ () const;
131 
135  Position3D operator- () const;
136 
141  Position3D& operator+= (const Position3D& pPos2);
142 
147  Position3D& operator-= (const Position3D& pPos2);
148 
153  bool operator== (const Position3D& pPos2) const;
154 
159  bool operator!= (const Position3D& pPos2) const;
160 
165  Position3D operator* (float pVal) const;
166 
171  Position3D operator/ (float pVal) const;
172 
177  Position3D& operator*= (float pVal);
178 
183  Position3D& operator/= (float pVal);
184 
195  float distanceSquared(const Position3D& pPos2) const;
196 
207  float distance(const Position3D& pPos2) const;
208 
219  bool isNear(
220  const Position3D& pPos2,
221  const float& pEpsilon=0.0001f) const;
222 
231  float norm() const;
232 
241  Position3D normalize() const;
242 
253  float dotProduct(const Position3D& pPos2) const;
254 
267  Position3D crossProduct(const Position3D& pPos2) const;
268 
272  std::vector<float> toVector() const;
273  };
274 
275  // TODO : Need this ?
277  const float pM,
278  const Position3D& pPos1);
279 
280  // Does it make sense to define 2.0 / Position3D() ??
281  Position3D operator/ (
282  const float pM,
283  const Position3D& pPos1);
284 
296  float distanceSquared(
297  const Position3D& pPos1,
298  const Position3D& pPos2);
299 
311  float distance(
312  const Position3D& pPos1,
313  const Position3D& pPos2);
314 
325  float norm(const Position3D& pPos);
326 
337  Position3D normalize(const Position3D& pPos);
338 
349  float dotProduct(
350  const Position3D& pPos1,
351  const Position3D& pPos2);
352 
366  const Position3D& pPos1,
367  const Position3D& pPos2);
368 
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_