libalmath  1.14.5
almath/types/alposition2d.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_ALPOSITION2D_H_
00010 #define _LIBALMATH_ALMATH_TYPES_ALPOSITION2D_H_
00011 
00012 #include <vector>
00013 
00014 namespace AL {
00015   namespace Math {
00016 
00023     struct Position2D
00024     {
00026       float x;
00028       float y;
00029 
00032 
00043 
00044       Position2D();
00045 
00048 
00059 
00060 
00061 
00062       explicit Position2D(float pInit);
00063 
00066 
00077 
00078 
00079 
00080       Position2D(float pX, float pY);
00081 
00084 
00095 
00096 
00097 
00098 
00099 
00100       Position2D(const std::vector<float>& pFloats);
00101 
00106       Position2D operator+ (const Position2D& pPos2) const;
00107 
00112       Position2D operator- (const Position2D& pPos2) const;
00113 
00117       Position2D operator+ () const;
00118 
00122       Position2D operator- () const;
00123 
00128       Position2D& operator+= (const Position2D& pPos2);
00129 
00134       Position2D& operator-= (const Position2D& pPos2);
00135 
00143       bool operator==(const Position2D& pPos2) const;
00144 
00152       bool operator!=(const Position2D& pPos2) const;
00153 
00158       Position2D operator* (float pVal) const;
00159 
00164       Position2D operator/ (float pVal) const;
00165 
00170       Position2D& operator*= (float pVal);
00171 
00176       Position2D& operator/= (float pVal);
00177 
00188       float distanceSquared(const Position2D& pPos2) const;
00189 
00200       float distance(const Position2D& pPos2) const;
00201 
00211       bool isNear(
00212         const Position2D& pPos2,
00213         const float&      pEpsilon=0.0001f) const;
00214 
00223       float norm() const;
00224 
00233       Position2D normalize() const;
00234 
00245       float crossProduct(const Position2D& pPos2) const;
00246 
00250       std::vector<float> toVector() const;
00251     };
00252 
00253     // TODO : Need this ?
00254     Position2D operator* (
00255       const float       pM,
00256       const Position2D& pPos1);
00257 
00269     float distanceSquared(
00270       const Position2D& pPos1,
00271       const Position2D& pPos2);
00272 
00284     float distance(
00285       const Position2D& pPos1,
00286       const Position2D& pPos2);
00287 
00298     float norm(const Position2D& pPos);
00299 
00310     Position2D normalize(const Position2D& pPos);
00311 
00323     float crossProduct(
00324       const Position2D& pPos1,
00325       const Position2D& pPos2);
00326 
00337     void crossProduct(
00338       const Position2D& pPos1,
00339       const Position2D& pPos2,
00340       float&            pRes);
00341 
00342   } // end namespace math
00343 } // end namespace al
00344 #endif  // _LIBALMATH_ALMATH_TYPES_ALPOSITION2D_H_
 All Classes Namespaces Functions Variables