GEL  2
GEL is a library for Geometry and Linear Algebra
/Users/jab/Documents/Teaching/02585/GEL2_and_demos/GEL/src/CGLA/ArithVecFloat.h
00001 #ifndef __CGLA__ARITHVECFLOAT_H__
00002 #define __CGLA__ARITHVECFLOAT_H__
00003 
00004 #include "ArithVec.h"
00005 
00006 namespace CGLA {
00007 
00008   template<class T, class V, unsigned int N>
00009     class ArithVecFloat: public ArithVec<T,V,N>
00010     {
00011     public:
00012           
00013       ArithVecFloat() 
00014         {
00015 #ifndef NDEBUG
00016           std::fill_n(this->data, N, CGLA_INIT_VALUE);
00017 #endif
00018         }
00019           
00020       ArithVecFloat(T a): 
00021         ArithVec<T,V,N>(a) {}
00022 
00023       ArithVecFloat(T a, T b): 
00024         ArithVec<T,V,N>(a,b) {}
00025 
00026       ArithVecFloat(T a, T b, T c): 
00027         ArithVec<T,V,N>(a,b,c) {}
00028 
00029       ArithVecFloat(T a, T b, T c, T d): 
00030         ArithVec<T,V,N>(a,b,c,d) {}
00031 
00033       T length() const 
00034         {
00035           return sqrt(sqr_length(*this));
00036         }
00037     
00039       void normalize() 
00040         {
00041           (*this) /= this->length();
00042         }
00043                 
00044     };
00045 
00047   template<class T, class V, unsigned int N>
00048     inline T length(const ArithVecFloat<T,V,N>& v) 
00049     {
00050       return v.length();
00051     }
00052         
00053         
00055   template<class T, class V, unsigned int N>
00056     inline V normalize(const ArithVecFloat<T,V,N>& v) 
00057     {
00058       return v/v.length();
00059     }
00060 }
00061 
00062 #endif
00063 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations