Commit 19c327d5 authored by Jund Thomas's avatar Jund Thomas

adding normalized() function in vec_gen

parent 0fafffbe
......@@ -127,8 +127,16 @@ public:
double norm() const ;
/*
* normalize the vector and returns its norm
*/
double normalize() ;
/*
* Return a normalized copy
*/
Vector<DIM, T> normalized() const;
// dot product
T operator*(const Vector<DIM, T> v) const ;
......
......@@ -256,6 +256,14 @@ inline double Vector<DIM, T>::normalize()
return n ;
}
template <unsigned int DIM, typename T>
inline Vector<DIM, T> Vector<DIM, T>::normalized() const
{
Vector<DIM, T> v(*this);
v.normalize();
return v;
}
template <unsigned int DIM, typename T>
inline T Vector<DIM, T>::operator*(const Vector<DIM, T> v) const
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment