Subversion Repositories gelsvn

Rev

Rev 10 | Rev 43 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#ifndef __CGLA__ARITHVECFLOAT_H__
#define __CGLA__ARITHVECFLOAT_H__

#include "ArithVec.h"

namespace CGLA {

  template<class T, class V, int N>
    class ArithVecFloat: public ArithVec<T,V,N>
    {
#define for_all_i(expr) for(int i=0;i<N;i++) {expr;}

    public:
          
      ArithVecFloat() 
        {
#ifndef NDEBUG
          for_all_i(data[i]=CGLA_INIT_VALUE);
#endif
        }
          
      ArithVecFloat(T a): 
        ArithVec<T,V,N>(a) {}

      ArithVecFloat(T a, T b): 
        ArithVec<T,V,N>(a,b) {}

      ArithVecFloat(T a, T b, T c): 
        ArithVec<T,V,N>(a,b,c) {}

      ArithVecFloat(T a, T b, T c, T d): 
        ArithVec<T,V,N>(a,b,c,d) {}

      /// Compute Euclidean length.
      T length() const 
        {
          return sqrt(sqr_length(*this));
        }
    
      /// Normalize vector.
      void normalize() 
        {
          (*this) /= length();
        }
                
    };

  /// Returns normalized vector
  template<class T, class V, int N>
    inline T length(const ArithVecFloat<T,V,N>& v) 
    {
      return v.length();
    }
        
        
  /// Returns normalized vector
  template<class T, class V, int N>
    inline V normalize(const ArithVecFloat<T,V,N>& v) 
    {
      return v/v.length();
    }
#undef for_all_i
}

#endif