libalmath  1.14.5
almath/types/alposition3d.h
00001 /*
00002  * Copyright (c) 2012 Aldebaran Robotics. All rights reserved.
00003  * Use of this source code is governed by a BSD-style license that can be
00004  * found in the COPYING file.
00005  */
00006 
00007 
00008 #pragma once
00009 #ifndef _LIBALMATH_ALMATH_TYPES_ALPOSITION3D_H_
00010 #define _LIBALMATH_ALMATH_TYPES_ALPOSITION3D_H_
00011 
00012 #include <vector>
00013 
00014 namespace AL {
00015   namespace Math {
00016 
00023     struct Position3D {
00025       float x;
00027       float y;
00029       float z;
00030 
00033 
00046 
00047       Position3D();
00048 
00051 
00064 
00065 
00066 
00067       explicit Position3D(float pInit);
00068 
00071 
00084 
00085 
00086 
00087 
00088       Position3D(
00089         float pX,
00090         float pY,
00091         float pZ);
00092 
00095 
00108 
00109 
00110 
00111 
00112 
00113       Position3D (const std::vector<float>& pFloats);
00114 
00119       Position3D operator+ (const Position3D& pPos2) const;
00120 
00125       Position3D operator- (const Position3D& pPos2) const;
00126 
00130       Position3D operator+ () const;
00131 
00135       Position3D operator- () const;
00136 
00141       Position3D& operator+= (const Position3D& pPos2);
00142 
00147       Position3D& operator-= (const Position3D& pPos2);
00148 
00153       bool operator== (const Position3D& pPos2) const;
00154 
00159       bool operator!= (const Position3D& pPos2) const;
00160 
00165       Position3D operator* (float pVal) const;
00166 
00171       Position3D operator/ (float pVal) const;
00172 
00177       Position3D& operator*= (float pVal);
00178 
00183       Position3D& operator/= (float pVal);
00184 
00195       float distanceSquared(const Position3D& pPos2) const;
00196 
00207       float distance(const Position3D& pPos2) const;
00208 
00219       bool isNear(
00220         const Position3D& pPos2,
00221         const float&      pEpsilon=0.0001f) const;
00222 
00231       float norm() const;
00232 
00241       Position3D normalize() const;
00242 
00253       float dotProduct(const Position3D& pPos2) const;
00254 
00267       Position3D crossProduct(const Position3D& pPos2) const;
00268 
00272       std::vector<float> toVector() const;
00273     };
00274 
00275     // TODO : Need this ?
00276     Position3D operator* (
00277       const float       pM,
00278       const Position3D& pPos1);
00279 
00280     // Does it make sense to define 2.0 / Position3D() ??
00281     Position3D operator/ (
00282       const float       pM,
00283       const Position3D& pPos1);
00284 
00296     float distanceSquared(
00297       const Position3D& pPos1,
00298       const Position3D& pPos2);
00299 
00311     float distance(
00312       const Position3D& pPos1,
00313       const Position3D& pPos2);
00314 
00325     float norm(const Position3D& pPos);
00326 
00337     Position3D normalize(const Position3D& pPos);
00338 
00349     float dotProduct(
00350       const Position3D& pPos1,
00351       const Position3D& pPos2);
00352 
00365     Position3D crossProduct(
00366       const Position3D& pPos1,
00367       const Position3D& pPos2);
00368 
00382     void crossProduct(
00383       const Position3D& pPos1,
00384       const Position3D& pPos2,
00385       Position3D&       pRes);
00386 
00387   } // end namespace math
00388 } // end namespace al
00389 #endif  // _LIBALMATH_ALMATH_TYPES_ALPOSITION3D_H_
 All Classes Namespaces Functions Variables