3D vector More...

#include <line_ray.h>

Public Types

typedef Type datatype
 

Public Member Functions

 Vec3 ()
 
 Vec3 (const Type &scalar)
 
 Vec3 (const Vec2< Type > &copy, const Type &p3)
 
 Vec3 (const Vec4< Type > &copy)
 
 Vec3 (const Vec3< double > &copy)
 
 Vec3 (const Vec3< float > &copy)
 
 Vec3 (const Vec3< int > &copy)
 
 Vec3 (const Type &p1, const Type &p2, const Type &p3)
 
 Vec3 (const Type *array_xyz)
 
template<>
 Vec3 (const Vec3< float > &copy)
 
template<>
 Vec3 (const Vec3< double > &copy)
 
template<>
 Vec3 (const Vec3< int > &copy)
 
template<>
 Vec3 (const Vec3< float > &copy)
 
template<>
 Vec3 (const Vec3< double > &copy)
 
template<>
 Vec3 (const Vec3< int > &copy)
 
template<>
 Vec3 (const Vec3< float > &copy)
 
template<>
 Vec3 (const Vec3< double > &copy)
 
template<>
 Vec3 (const Vec3< int > &copy)
 
template<>
 Vec3 (const Vec3< float > &copy)
 
template<>
 Vec3 (const Vec3< double > &copy)
 
template<>
 Vec3 (const Vec3< int > &copy)
 
template<>
 Vec3 (const Vec3< float > &copy)
 
template<>
 Vec3 (const Vec3< double > &copy)
 
template<>
 Vec3 (const Vec3< int > &copy)
 
template<>
 Vec3 (const Vec3< float > &copy)
 
template<>
 Vec3 (const Vec3< double > &copy)
 
template<>
 Vec3 (const Vec3< int > &copy)
 
template<>
 Vec3 (const Vec3< float > &copy)
 
template<>
 Vec3 (const Vec3< double > &copy)
 
template<>
 Vec3 (const Vec3< int > &copy)
 
template<>
 Vec3 (const Vec3< float > &copy)
 
template<>
 Vec3 (const Vec3< double > &copy)
 
template<>
 Vec3 (const Vec3< int > &copy)
 
Angle angle (const Vec3< Type > &vector) const
 Calculate the angle between this vector and an other vector. More...
 
Angle angle_normed (const Vec3< Type > &vector) const
 Calculate the angle between this vector and an other vector, where the vectors are unit vectors. More...
 
Vec3< Type > & cross (const Vec3< Type > &vector)
 Calculate the cross product between this vector and an other vector. More...
 
Type distance (const Vec3< Type > &vector) const
 Calculate the distance between this vector and an other vector. More...
 
Type dot (const Vec3< Type > &vector) const
 Dot products this vector with an other vector. More...
 
bool is_equal (const Vec3< Type > &other, Type epsilon) const
 Returns true if equal within the bounds of an epsilon. More...
 
Type length () const
 Returns the length (magnitude) of this vector. More...
 
template<>
double length () const
 
template<>
float length () const
 
Vec3< Type > & normalize ()
 Normalizes this vector. More...
 
bool operator!= (const Vec3< Type > &vector) const
 != operator. More...
 
void operator*= (const Vec3< Type > &vector)
 *= operator. More...
 
void operator*= (Type value)
 *= operator. More...
 
void operator+= (const Vec3< Type > &vector)
 += operator. More...
 
void operator+= (Type value)
 += operator. More...
 
Vec3< Type > operator- () const
 
  • operator.
More...
 
void operator-= (const Vec3< Type > &vector)
 -= operator. More...
 
void operator-= (Type value)
 -= operator. More...
 
void operator/= (const Vec3< Type > &vector)
 /= operator. More...
 
void operator/= (Type value)
 /= operator. More...
 
bool operator< (const Vec3< Type > &vector) const
 < operator. More...
 
Vec3< Type > & operator= (const Vec3< Type > &vector)
 = operator. More...
 
bool operator== (const Vec3< Type > &vector) const
 == operator. More...
 
Vec3< Type > & rotate (const Angle &angle, const Vec3< Type > &axis)
 Rotate this vector around an axis. Same as glRotate[f|d](angle, a);. More...
 
Vec3< Type > & round ()
 Rounds all components on this vector. More...
 

Static Public Member Functions

static Vec3< Type > cross (const Vec3< Type > &vector1, const Vec3< Type > &vector2)
 Calculate the cross product between two vectors. More...
 
static Type dot (const Vec3< Type > &vector1, const Vec3< Type > &vector2)
 Dot products between two vectors. More...
 
static bool is_equal (const Vec3< Type > &first, const Vec3< Type > &second, Type epsilon)
 Returns true if equal within the bounds of an epsilon. More...
 
static Vec3< Type > normalize (const Vec3< Type > &vector)
 Normalizes a vector. More...
 
static Vec3< Type > reflect (const Vec3< Type > &incident, const Vec3< Type > &normal)
 Calculate the reflection direction for an incident vector. More...
 
static Vec3< Type > rotate (const Vec3< Type > &vector, const Angle &angle, const Vec3< Type > &axis)
 Rotate a vector around an axis. Same as glRotate[f|d](angle, a);. More...
 
static Vec3< Type > round (const Vec3< Type > &vector)
 Rounds all components on a vector. More...
 

Public Attributes

union {
   Type   r
 
   Type   s
 
   Type   x
 
}; 
 
union {
   Type   g
 
   Type   t
 
   Type   y
 
}; 
 
union {
   Type   b
 
   Type   u
 
   Type   z
 
}; 
 

Detailed Description

template<typename Type>
singleton clan::Vec3< Type >

3D vector

These vector templates are defined for:
char (Vec3c), unsigned char (Vec3uc), short (Vec3s),
unsigned short (Vec3us), int (Vec3i), unsigned int (Vec3ui), float (Vecdf), double (Vec3d)

Member Typedef Documentation

template<typename Type>
typedef Type clan::Vec3< Type >::datatype

Constructor & Destructor Documentation

template<typename Type>
clan::Vec3< Type >::Vec3 ( )
inline
template<typename Type>
clan::Vec3< Type >::Vec3 ( const Type &  scalar)
inlineexplicit
template<typename Type>
clan::Vec3< Type >::Vec3 ( const Vec2< Type > &  copy,
const Type &  p3 
)
inlineexplicit
template<typename Type>
clan::Vec3< Type >::Vec3 ( const Vec4< Type > &  copy)
inlineexplicit
template<typename Type>
clan::Vec3< Type >::Vec3 ( const Vec3< double > &  copy)
template<typename Type>
clan::Vec3< Type >::Vec3 ( const Vec3< float > &  copy)
template<typename Type>
clan::Vec3< Type >::Vec3 ( const Vec3< int > &  copy)
template<typename Type>
clan::Vec3< Type >::Vec3 ( const Type &  p1,
const Type &  p2,
const Type &  p3 
)
inlineexplicit
template<typename Type>
clan::Vec3< Type >::Vec3 ( const Type *  array_xyz)
inlineexplicit
template<>
clan::Vec3< unsigned char >::Vec3 ( const Vec3< float > &  copy)
inline
template<>
clan::Vec3< unsigned char >::Vec3 ( const Vec3< double > &  copy)
inline
template<>
clan::Vec3< unsigned char >::Vec3 ( const Vec3< int > &  copy)
inline
template<>
clan::Vec3< char >::Vec3 ( const Vec3< float > &  copy)
inline
template<>
clan::Vec3< char >::Vec3 ( const Vec3< double > &  copy)
inline
template<>
clan::Vec3< char >::Vec3 ( const Vec3< int > &  copy)
inline
template<>
clan::Vec3< unsigned short >::Vec3 ( const Vec3< float > &  copy)
inline
template<>
clan::Vec3< unsigned short >::Vec3 ( const Vec3< double > &  copy)
inline
template<>
clan::Vec3< unsigned short >::Vec3 ( const Vec3< int > &  copy)
inline
template<>
clan::Vec3< short >::Vec3 ( const Vec3< float > &  copy)
inline
template<>
clan::Vec3< short >::Vec3 ( const Vec3< double > &  copy)
inline
template<>
clan::Vec3< short >::Vec3 ( const Vec3< int > &  copy)
inline
template<>
clan::Vec3< int >::Vec3 ( const Vec3< float > &  copy)
inline
template<>
clan::Vec3< int >::Vec3 ( const Vec3< double > &  copy)
inline
template<>
clan::Vec3< int >::Vec3 ( const Vec3< int > &  copy)
inline
template<>
clan::Vec3< unsigned int >::Vec3 ( const Vec3< float > &  copy)
inline
template<>
clan::Vec3< unsigned int >::Vec3 ( const Vec3< double > &  copy)
inline
template<>
clan::Vec3< unsigned int >::Vec3 ( const Vec3< int > &  copy)
inline
template<>
clan::Vec3< float >::Vec3 ( const Vec3< float > &  copy)
inline
template<>
clan::Vec3< float >::Vec3 ( const Vec3< double > &  copy)
inline
template<>
clan::Vec3< float >::Vec3 ( const Vec3< int > &  copy)
inline
template<>
clan::Vec3< double >::Vec3 ( const Vec3< float > &  copy)
inline
template<>
clan::Vec3< double >::Vec3 ( const Vec3< double > &  copy)
inline
template<>
clan::Vec3< double >::Vec3 ( const Vec3< int > &  copy)
inline

Member Function Documentation

template<typename Type>
Angle clan::Vec3< Type >::angle ( const Vec3< Type > &  vector) const

Calculate the angle between this vector and an other vector.

Parameters
vectorSecond vector used to calculate angle.
Returns
The angle between the two vectors.
template<typename Type>
Angle clan::Vec3< Type >::angle_normed ( const Vec3< Type > &  vector) const

Calculate the angle between this vector and an other vector, where the vectors are unit vectors.

Parameters
vectorSecond vector used to calculate angle.
Returns
The angle between the two vectors.
template<typename Type>
static Vec3<Type> clan::Vec3< Type >::cross ( const Vec3< Type > &  vector1,
const Vec3< Type > &  vector2 
)
static

Calculate the cross product between two vectors.

Parameters
vector1= The first vector
vector2= The second vector
Returns
The cross product
template<typename Type>
Vec3<Type>& clan::Vec3< Type >::cross ( const Vec3< Type > &  vector)

Calculate the cross product between this vector and an other vector.

Operates in the native datatype

Parameters
vector= Second vector used to perform the calculation.
Returns
reference to this object
template<typename Type>
Type clan::Vec3< Type >::distance ( const Vec3< Type > &  vector) const

Calculate the distance between this vector and an other vector.

Parameters
vector= Second vector used to calculate distance.
Returns
The distance between the two vectors.
template<typename Type>
static Type clan::Vec3< Type >::dot ( const Vec3< Type > &  vector1,
const Vec3< Type > &  vector2 
)
inlinestatic

Dot products between two vectors.

Returns
The dot product
template<typename Type>
Type clan::Vec3< Type >::dot ( const Vec3< Type > &  vector) const
inline

Dot products this vector with an other vector.

Operates in the native datatype

Parameters
vectorSecond vector used for the dot product.
Returns
The resulting dot product of the two vectors.
template<typename Type>
static bool clan::Vec3< Type >::is_equal ( const Vec3< Type > &  first,
const Vec3< Type > &  second,
Type  epsilon 
)
inlinestatic

Returns true if equal within the bounds of an epsilon.

Parameters
first= Value A
second= Value B
epsilon= The epsilon (eg FLT_EPSILON/2, DBL_EPSILON/2)

Referenced by clan::Vec3< int >::is_equal().

template<typename Type>
bool clan::Vec3< Type >::is_equal ( const Vec3< Type > &  other,
Type  epsilon 
) const
inline

Returns true if equal within the bounds of an epsilon.

Parameters
other= Other value
epsilon= The epsilon (eg FLT_EPSILON/2, DBL_EPSILON/2)
template<>
double clan::Vec3< double >::length ( ) const
inline

References clan::x, clan::y, and clan::z.

template<>
float clan::Vec3< float >::length ( ) const
inline

References clan::x, clan::y, and clan::z.

template<typename Type>
bool clan::Vec3< Type >::operator!= ( const Vec3< Type > &  vector) const
inline

!= operator.

template<typename Type>
void clan::Vec3< Type >::operator*= ( const Vec3< Type > &  vector)
inline

*= operator.

template<typename Type>
void clan::Vec3< Type >::operator*= ( Type  value)
inline

*= operator.

template<typename Type>
void clan::Vec3< Type >::operator+= ( const Vec3< Type > &  vector)
inline

+= operator.

template<typename Type>
void clan::Vec3< Type >::operator+= ( Type  value)
inline

+= operator.

template<typename Type>
Vec3<Type> clan::Vec3< Type >::operator- ( ) const
inline

  • operator.

template<typename Type>
void clan::Vec3< Type >::operator-= ( const Vec3< Type > &  vector)
inline

-= operator.

template<typename Type>
void clan::Vec3< Type >::operator-= ( Type  value)
inline

-= operator.

template<typename Type>
void clan::Vec3< Type >::operator/= ( const Vec3< Type > &  vector)
inline

/= operator.

template<typename Type>
void clan::Vec3< Type >::operator/= ( Type  value)
inline

/= operator.

template<typename Type>
bool clan::Vec3< Type >::operator< ( const Vec3< Type > &  vector) const
inline

< operator.

template<typename Type>
Vec3<Type>& clan::Vec3< Type >::operator= ( const Vec3< Type > &  vector)
inline

= operator.

template<typename Type>
bool clan::Vec3< Type >::operator== ( const Vec3< Type > &  vector) const
inline

== operator.

template<typename Type>
static Vec3<Type> clan::Vec3< Type >::reflect ( const Vec3< Type > &  incident,
const Vec3< Type > &  normal 
)
static

Calculate the reflection direction for an incident vector.

Normal vector should be normalized

template<typename Type>
static Vec3<Type> clan::Vec3< Type >::rotate ( const Vec3< Type > &  vector,
const Angle angle,
const Vec3< Type > &  axis 
)
static

Rotate a vector around an axis. Same as glRotate[f|d](angle, a);.

Parameters
vector= Vector to use
angle= Angle to rotate.
axis= Rotation axis.
Returns
The rotated vector
template<typename Type>
Vec3<Type>& clan::Vec3< Type >::rotate ( const Angle angle,
const Vec3< Type > &  axis 
)

Rotate this vector around an axis. Same as glRotate[f|d](angle, a);.

Parameters
angleAngle to rotate.
axisRotation axis.
Returns
reference to this object
template<typename Type>
static Vec3<Type> clan::Vec3< Type >::round ( const Vec3< Type > &  vector)
static

Rounds all components on a vector.

Uses Asymmetric Arithmetic Rounding

Parameters
vector= Vector to use
Returns
The rounded vector
template<typename Type>
Vec3<Type>& clan::Vec3< Type >::round ( )

Rounds all components on this vector.

Uses Asymmetric Arithmetic Rounding

Returns
reference to this object

Member Data Documentation

union { ... }
union { ... }
union { ... }
template<typename Type>
Type clan::Vec3< Type >::b
template<typename Type>
Type clan::Vec3< Type >::g
template<typename Type>
Type clan::Vec3< Type >::r
template<typename Type>
Type clan::Vec3< Type >::s
template<typename Type>
Type clan::Vec3< Type >::t
template<typename Type>
Type clan::Vec3< Type >::u

The documentation for this singleton was generated from the following files: