@ -42,6 +42,7 @@
# define VECTOR3_H
# define VECTOR3_H
# include <math.h>
# include <math.h>
# include <string.h>
template < typename T >
template < typename T >
class Vector3
class Vector3
@ -50,7 +51,7 @@ public:
T x , y , z ;
T x , y , z ;
// trivial ctor
// trivial ctor
Vector3 < T > ( ) : x ( 0 ) , y ( 0 ) , z ( 0 ) { }
Vector3 < T > ( ) { memset ( this , 0 , sizeof ( * this ) ) ; }
// setting ctor
// setting ctor
Vector3 < T > ( const T x0 , const T y0 , const T z0 ) : x ( x0 ) , y ( y0 ) , z ( z0 ) { }
Vector3 < T > ( const T x0 , const T y0 , const T z0 ) : x ( x0 ) , y ( y0 ) , z ( z0 ) { }
@ -165,11 +166,11 @@ public:
{ return v * ( * this * v ) / ( v * v ) ; }
{ return v * ( * this * v ) / ( v * v ) ; }
// computes the angle between 2 arbitrary vectors
// computes the angle between 2 arbitrary vectors
static inline T angle ( const Vector3 < T > & v1 , const Vector3 < T > & v2 )
T angle ( const Vector3 < T > & v1 , const Vector3 < T > & v2 )
{ return ( T ) acosf ( ( v1 * v2 ) / ( v1 . length ( ) * v2 . length ( ) ) ) ; }
{ return ( T ) acosf ( ( v1 * v2 ) / ( v1 . length ( ) * v2 . length ( ) ) ) ; }
// computes the angle between 2 arbitrary normalized vectors
// computes the angle between 2 arbitrary normalized vectors
static inline T angle_normalized ( const Vector3 < T > & v1 , const Vector3 < T > & v2 )
T angle_normalized ( const Vector3 < T > & v1 , const Vector3 < T > & v2 )
{ return ( T ) acosf ( v1 * v2 ) ; }
{ return ( T ) acosf ( v1 * v2 ) ; }
} ;
} ;