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)
 
Type angle (const Vec3< Type > &vector) const
 Calculate the angle between this vector and an other vector. More...
 
Type 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 (Type 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, Type 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

Type x
 
Type y
 
Type z
 

Detailed Description

template<typename Type>
class uicore::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 uicore::Vec3< Type >::datatype

Constructor & Destructor Documentation

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

Member Function Documentation

template<typename Type>
Type uicore::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>
Type uicore::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> uicore::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>& uicore::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 uicore::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 uicore::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 uicore::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 uicore::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 uicore::Vec3< int >::is_equal().

template<typename Type>
bool uicore::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<typename Type >
Type uicore::Vec3< Type >::length ( ) const
inline

Returns the length (magnitude) of this vector.

Operates in the native datatype

Returns
the length of the vector

References uicore::f, uicore::x, uicore::y, and uicore::z.

template<>
double uicore::Vec3< double >::length ( ) const
inline

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

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

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

template<typename Type>
Vec3< Type > uicore::Vec3< Type >::normalize ( const Vec3< Type > &  vector)
inlinestatic

Normalizes a vector.

Parameters
vector= Vector to use

Operates in the native datatype

template<typename Type>
Vec3< Type > & uicore::Vec3< Type >::normalize ( )
inline

Normalizes this vector.

Operates in the native datatype

Returns
reference to this object

References uicore::f, uicore::length, uicore::x, uicore::y, and uicore::z.

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

!= operator.

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

*= operator.

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

*= operator.

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

+= operator.

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

+= operator.

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

  • operator.

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

-= operator.

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

-= operator.

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

/= operator.

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

/= operator.

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

< operator.

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

= operator.

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

== operator.

template<typename Type>
static Vec3<Type> uicore::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> uicore::Vec3< Type >::rotate ( const Vec3< Type > &  vector,
Type  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>& uicore::Vec3< Type >::rotate ( Type  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> uicore::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>& uicore::Vec3< Type >::round ( )

Rounds all components on this vector.

Uses Asymmetric Arithmetic Rounding

Returns
reference to this object

Member Data Documentation


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