$search
00001 /* 00002 * Copyright (C) 2009 00003 * Robert Bosch LLC 00004 * Research and Technology Center North America 00005 * Palo Alto, California 00006 * 00007 * All rights reserved. 00008 * 00009 *------------------------------------------------------------------------------ 00010 * project ....: Autonomous Technologies 00011 * file .......: Point2D.h 00012 * authors ....: Benjamin Pitzer 00013 * organization: Robert Bosch LLC 00014 * creation ...: 08/22/2008 00015 * modified ...: $Date:2008-03-03 10:26:02 -0800 (Mon, 03 Mar 2008) $ 00016 * changed by .: $Author:benjaminpitzer $ 00017 * revision ...: $Revision:141 $ 00018 */ 00019 #ifndef RTC_POINT2D_H 00020 #define RTC_POINT2D_H 00021 00022 //== INCLUDES ================================================================== 00023 #include "rtc/rtcMath.h" 00024 #include "rtc/rtcVec2.h" 00025 00026 //== NAMESPACES ================================================================ 00027 namespace rtc { 00028 00029 //== CLASS DEFINITION ========================================================== 00030 00031 template <class T> 00032 class Point2D: public Vec2<T> { 00033 public: 00034 using Vec<T, 2>::x; 00035 Point2D(T x = 0, T y = 0) : 00036 Vec2<T> (x, y) { 00037 } 00038 00039 Point2D(const Vec<T, 2> &other) : 00040 Vec2<T> (other) { 00041 } 00042 00043 float distanceTo(Point2D<T> other) { 00044 return (*this - other).norm(); 00045 } 00046 00047 const Point2D &operator=(const Point2D &other) { 00048 x[0] = other.x[0]; 00049 x[1] = other.x[1]; 00050 return *this; 00051 } 00052 00053 const Point2D &operator=(const Vec<T, 2> other) { 00054 x[0] = other.x[0]; 00055 x[1] = other.x[1]; 00056 return *this; 00057 } 00058 }; 00059 00060 typedef Point2D<int> Point2Di; 00061 typedef Point2D<unsigned int> Point2Dui; 00062 typedef Point2D<float> Point2Df; 00063 typedef Point2D<double> Point2Dd; 00064 00065 //============================================================================== 00066 } // NAMESPACE rtc 00067 //============================================================================== 00068 #endif // RTC_POINT2D_H defined 00069 //==============================================================================