rtcPoint3D.h
Go to the documentation of this file.
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 .......: rtcPoint3D.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_POINT3D_H
00020 #define RTC_POINT3D_H
00021 
00022 //== INCLUDES ==================================================================
00023 #include "rtc/rtcMath.h"
00024 #include "rtc/rtcVec3.h"
00025 
00026 //== NAMESPACES ================================================================
00027 namespace rtc {
00028 
00029 //== CLASS DEFINITION ==========================================================
00030 
00031 template <class T>
00032 class Point3D: public Vec3<T> {
00033  public:
00034   using Vec<T, 3>::x;
00035 
00036   Point3D(T x = 0, T y = 0, T z = 0) :
00037     Vec3<T> (x, y, z) {
00038   }
00039 
00040   Point3D(const Vec<T, 3> &other) :
00041     Vec3<T> (other) {
00042   }
00043 
00044   template <class U>
00045   Point3D(const Vec<U, 3> &other) :
00046     Vec3<T> (other) {
00047   }
00048 
00049   T distanceTo(Point3D<T> other) const {
00050     return (*this - other).norm();
00051   }
00052 
00053   T distanceToSqr(Point3D<T> other) const {
00054     return (*this - other).normSqr();
00055   }
00056 
00057   template <class U>
00058   const Point3D<T> &operator=(const Vec<U, 3> &other) {
00059     x[0] = static_cast<T>(other.x[0]);
00060     x[1] = static_cast<T>(other.x[1]);
00061     x[2] = static_cast<T>(other.x[2]);
00062     return *this;
00063   }
00064 
00065   const Point3D<T> &operator=(const Vec<T, 3> &other) {
00066     x[0] = other.x[0];
00067     x[1] = other.x[1];
00068     x[2] = other.x[2];
00069     return *this;
00070   }
00071 
00072   const Point3D<T> &operator=(const Point3D other) {
00073     x[0] = other.x[0];
00074     x[1] = other.x[1];
00075     x[2] = other.x[2];
00076     return *this;
00077   }
00078 };
00079 
00080 typedef Point3D<int> Point3Di;
00081 typedef Point3D<unsigned int> Point3Dui;
00082 typedef Point3D<float> Point3Df;
00083 typedef Point3D<double> Point3Dd;
00084 
00085 //==============================================================================
00086 } // NAMESPACE rtc
00087 //==============================================================================
00088 #endif // RTC_POINT3D_H defined
00089 //==============================================================================


rtc
Author(s): Benjamin Pitzer
autogenerated on Thu Jan 2 2014 11:04:53