rtcVec3.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2008
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 .......: Vec3.h
00012  * authors ....: Benjamin Pitzer
00013  * organization: Robert Bosch LLC
00014  * creation ...: 08/16/2006
00015  * modified ...: $Date: 2009-01-21 18:19:16 -0800 (Wed, 21 Jan 2009) $
00016  * changed by .: $Author: benjaminpitzer $
00017  * revision ...: $Revision: 14 $
00018  */
00019 #ifndef RTC_VEC3_H
00020 #define RTC_VEC3_H
00021 
00022 //== INCLUDES ==================================================================
00023 #include "rtc/rtcMath.h"
00024 #include "rtc/rtcVec.h"
00025 
00026 //== NAMESPACES ================================================================
00027 namespace rtc {
00028 
00029 // Forward declarations
00030 template <class T, int M> class Vec; // M-d vector
00031 template <class T> class Vec3; // 3d Vector
00032 template <class T> class SMat3; // 3x3 square matrix
00033 
00037 template <class T>
00038 class Vec3: public Vec<T,3> {
00039 public:
00040   // Constructors
00041   Vec3();
00042   Vec3(const T* d);
00043   Vec3(const T a);
00044   Vec3(const T x0, const T x1, const T x2);
00045   Vec3(const Vec<T,3>& v);
00046 
00047   // Cast Operation
00048   template <class U> Vec3(const Vec<U,3>& v);
00049 
00050   // Mutators
00051   void set(const T x0, const T x1, const T x2);
00052 
00053   // Cross Product
00054   Vec3<T> cross(const Vec3<T>& v) const;
00055 
00056   // Cross Product operator
00057   inline Vec3<T> operator%(const Vec3<T>& v) const;
00058 
00059   // inherit member data and functions of parent
00060   using Vec<T,3>::x;
00061   using Vec<T,3>::set;
00062 };
00063 
00064 // Declare a few common typdefs
00065 typedef Vec3<bool> Vec3b;
00066 typedef Vec3<signed char> Vec3c;
00067 typedef Vec3<unsigned char> Vec3uc;
00068 typedef Vec3<signed short int> Vec3s;
00069 typedef Vec3<unsigned short int> Vec3us;
00070 typedef Vec3<int> Vec3i;
00071 typedef Vec3<unsigned int> Vec3ui;
00072 typedef Vec3<float> Vec3f;
00073 typedef Vec3<double> Vec3d;
00074 
00075 //==============================================================================
00076 // Vec3<T>
00077 //==============================================================================
00078 
00079 // Constructors
00080 
00083 template <class T>
00084 inline Vec3<T>::Vec3() {}
00085 
00088 template <class T>
00089 inline Vec3<T>::Vec3(const T* d) : Vec<T,3>(d) {}
00090 
00093 template <class T>
00094 inline Vec3<T>::Vec3(const T a) : Vec<T,3>(a) {}
00095 
00098 template <class T>
00099 inline Vec3<T>::Vec3(const T x0, const T x1, const T x2) {
00100   set(x0,x1,x2);
00101 }
00102 
00105 template <class T>
00106 inline Vec3<T>::Vec3(const Vec<T,3>& v) : Vec<T,3>(v){}
00107 
00108 // Casting Operation
00109 
00112 template <class T> template <class U>
00113 inline Vec3<T>::Vec3(const Vec<U,3>& v) : Vec<T,3>(v) {}
00114 
00115 
00116 // Mutators
00117 
00120 template <class T>
00121 inline void Vec3<T>::set(const T x0, const T x1, const T x2) {
00122   x[0] = x0; x[1] = x1; x[2] = x2;
00123 }
00124 
00125 // Cross Product
00126 
00131 template <class T>
00132 inline Vec3<T> Vec3<T>::cross(const Vec3<T>& v) const {
00133   return Vec3<T>(x[1]*v.x[2]-x[2]*v.x[1],
00134                  x[2]*v.x[0]-x[0]*v.x[2],
00135                  x[0]*v.x[1]-x[1]*v.x[0]);
00136 }
00137 
00140 template <class T>
00141 inline Vec3<T> Vec3<T>::operator%(const Vec3<T>& v) const {
00142   return cross(v);
00143 }
00144 
00145 //==============================================================================
00146 } // NAMESPACE rtc
00147 //==============================================================================
00148 #endif // RTC_VEC3_H defined
00149 //==============================================================================


rtc
Author(s): Benjamin Pitzer
autogenerated on Mon Oct 6 2014 10:07:35