Vector3< T > Class Template Reference

Class for three dimensional vector. More...

#include <vmath.h>

List of all members.

Public Member Functions

 Vector3 ()
 Creates and sets to (0,0,0).
 Vector3 (T nx, T ny, T nz)
 Creates and sets to (x,y,z).
 Vector3 (const Vector3< T > &src)
 Copy constructor.
template<class FromT >
 Vector3 (const Vector3< FromT > &src)
 Copy casting constructor.
Vector3< T > operator= (const Vector3< T > &rhs)
 Copy operator.
template<class FromT >
Vector3< T > operator= (const Vector3< FromT > &rhs)
 Copy casting operator.
T & operator[] (int n)
 Array access operator.
Vector3< T > operator+ (const Vector3< T > &rhs) const
 Addition operator.
Vector3< T > operator- (const Vector3< T > &rhs) const
 Substraction operator.
Vector3< T > operator* (const Vector3< T > &rhs) const
 Multiplication operator.
Vector3< T > operator/ (const Vector3< T > &rhs) const
 Division operator.
Vector3< T > & operator+= (const Vector3< T > &rhs)
 Addition operator.
Vector3< T > & operator-= (const Vector3< T > &rhs)
 Substraction operator.
Vector3< T > & operator*= (const Vector3< T > &rhs)
 Multiplication operator.
Vector3< T > & operator/= (const Vector3< T > &rhs)
 Division operator.
dotProduct (const Vector3< T > &rhs) const
 Dot product of two vectors.
Vector3< T > crossProduct (const Vector3< T > &rhs) const
 Cross product opertor.
Vector3< T > operator+ (T rhs) const
 Addition operator.
Vector3< T > operator- (T rhs) const
 Substraction operator.
Vector3< T > operator* (T rhs) const
 Multiplication operator.
Vector3< T > operator/ (T rhs) const
 Division operator.
Vector3< T > & operator+= (T rhs)
 Addition operator.
Vector3< T > & operator-= (T rhs)
 Substraction operator.
Vector3< T > & operator*= (T rhs)
 Multiplication operator.
Vector3< T > & operator/= (T rhs)
 Division operator.
bool operator== (const Vector3< T > &rhs) const
 Equality test operator.
bool operator!= (const Vector3< T > &rhs) const
 Inequality test operator.
Vector3< T > operator- () const
 Unary negate operator.
length () const
 Get lenght of vector.
lengthSq () const
 Return square of length.
void normalize ()
 Normalize vector.
void rotate (T ax, T ay, T az)
 Rotate vector around three axis.
Vector3< T > lerp (T fact, const Vector3< T > &r) const
 Linear interpolation of two vectors.
 operator T * ()
 Conversion to pointer operator.
 operator const T * () const
 Conversion to pointer operator.

Public Attributes

union {
   T   x
 First element of vector, alias for X-coordinate.
   T   s
 First element of vector, alias for S-coordinate.
   T   r
 First element of vector, alias for R-coordinate.
}; 
union {
   T   y
 Second element of vector, alias for Y-coordinate.
   T   t
 Second element of vector, alias for T-coordinate.
   T   g
 Second element of vector, alias for G-coordinate.
}; 
union {
   T   z
 Third element of vector, alias for Z-coordinate.
   T   u
 Third element of vector, alias for U-coordinate.
   T   b
 Third element of vector, alias for B-coordinate.
}; 

Friends

std::ostream & operator<< (std::ostream &lhs, const Vector3< T > rhs)
 Output to stream operator.


Detailed Description

template<class T>
class Vector3< T >

Class for three dimensional vector.

Constructor & Destructor Documentation

template<class T>
Vector3< T >::Vector3 (  )  [inline]

Creates and sets to (0,0,0).

template<class T>
Vector3< T >::Vector3 ( nx,
ny,
nz 
) [inline]

Creates and sets to (x,y,z).

Parameters:
nx intial x-coordinate value
ny intial y-coordinate value
nz intial z-coordinate value

template<class T>
Vector3< T >::Vector3 ( const Vector3< T > &  src  )  [inline]

Copy constructor.

Parameters:
src Source of data for new created Vector3 instance.

template<class T>
template<class FromT >
Vector3< T >::Vector3 ( const Vector3< FromT > &  src  )  [inline]

Copy casting constructor.

Parameters:
src Source of data for new created Vector3 instance.


Member Function Documentation

template<class T>
Vector3<T> Vector3< T >::crossProduct ( const Vector3< T > &  rhs  )  const [inline]

Cross product opertor.

Parameters:
rhs Right hand side argument of binary operator.

References Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

template<class T>
T Vector3< T >::dotProduct ( const Vector3< T > &  rhs  )  const [inline]

Dot product of two vectors.

Parameters:
rhs Right hand side argument of binary operator.

References Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

template<class T>
T Vector3< T >::length (  )  const [inline]

Get lenght of vector.

Returns:
lenght of vector

template<class T>
T Vector3< T >::lengthSq (  )  const [inline]

Return square of length.

Returns:
lenght ^ 2
Note:
This method is faster then length(). For comparsion of length of two vector can be used just this value, instead of computionaly more expensive length() method.

template<class T>
Vector3<T> Vector3< T >::lerp ( fact,
const Vector3< T > &  r 
) const [inline]

Linear interpolation of two vectors.

Parameters:
fact Factor of interpolation. For translation from positon of this vector to vector r, values of factor goes from 0.0 to 1.0.
r Second Vector for interpolation
Note:
Hovewer values of fact parameter are reasonable only in interval [0.0 , 1.0], you can pass also values outside of this interval and you can get result (extrapolation?)

template<class T>
void Vector3< T >::normalize (  )  [inline]

Normalize vector.

template<class T>
Vector3< T >::operator const T * (  )  const [inline]

Conversion to pointer operator.

Returns:
Constant Pointer to internaly stored (in managment of class Vector3<T>) used for passing Vector3<T> values to gl*3[fd] functions.

template<class T>
Vector3< T >::operator T * (  )  [inline]

Conversion to pointer operator.

Returns:
Pointer to internaly stored (in managment of class Vector3<T>) used for passing Vector3<T> values to gl*3[fd] functions.

template<class T>
bool Vector3< T >::operator!= ( const Vector3< T > &  rhs  )  const [inline]

Inequality test operator.

Parameters:
rhs Right hand side argument of binary operator.
Returns:
not (lhs == rhs) :-P

template<class T>
Vector3<T> Vector3< T >::operator* ( rhs  )  const [inline]

Multiplication operator.

Parameters:
rhs Right hand side argument of binary operator.

template<class T>
Vector3<T> Vector3< T >::operator* ( const Vector3< T > &  rhs  )  const [inline]

Multiplication operator.

Parameters:
rhs Right hand side argument of binary operator.

References Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

template<class T>
Vector3<T>& Vector3< T >::operator*= ( rhs  )  [inline]

Multiplication operator.

Parameters:
rhs Right hand side argument of binary operator.

template<class T>
Vector3<T>& Vector3< T >::operator*= ( const Vector3< T > &  rhs  )  [inline]

Multiplication operator.

Parameters:
rhs Right hand side argument of binary operator.

References Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

template<class T>
Vector3<T> Vector3< T >::operator+ ( rhs  )  const [inline]

Addition operator.

Parameters:
rhs Right hand side argument of binary operator.

template<class T>
Vector3<T> Vector3< T >::operator+ ( const Vector3< T > &  rhs  )  const [inline]

Addition operator.

Parameters:
rhs Right hand side argument of binary operator.

References Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

template<class T>
Vector3<T>& Vector3< T >::operator+= ( rhs  )  [inline]

Addition operator.

Parameters:
rhs Right hand side argument of binary operator.

template<class T>
Vector3<T>& Vector3< T >::operator+= ( const Vector3< T > &  rhs  )  [inline]

Addition operator.

Parameters:
rhs Right hand side argument of binary operator.

References Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

template<class T>
Vector3<T> Vector3< T >::operator- (  )  const [inline]

Unary negate operator.

Returns:
negated vector

template<class T>
Vector3<T> Vector3< T >::operator- ( rhs  )  const [inline]

Substraction operator.

Parameters:
rhs Right hand side argument of binary operator.

template<class T>
Vector3<T> Vector3< T >::operator- ( const Vector3< T > &  rhs  )  const [inline]

Substraction operator.

Parameters:
rhs Right hand side argument of binary operator.

References Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

template<class T>
Vector3<T>& Vector3< T >::operator-= ( rhs  )  [inline]

Substraction operator.

Parameters:
rhs Right hand side argument of binary operator.

template<class T>
Vector3<T>& Vector3< T >::operator-= ( const Vector3< T > &  rhs  )  [inline]

Substraction operator.

Parameters:
rhs Right hand side argument of binary operator.

References Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

template<class T>
Vector3<T> Vector3< T >::operator/ ( rhs  )  const [inline]

Division operator.

Parameters:
rhs Right hand side argument of binary operator.

template<class T>
Vector3<T> Vector3< T >::operator/ ( const Vector3< T > &  rhs  )  const [inline]

Division operator.

Parameters:
rhs Right hand side argument of binary operator.

References Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

template<class T>
Vector3<T>& Vector3< T >::operator/= ( rhs  )  [inline]

Division operator.

Parameters:
rhs Right hand side argument of binary operator.

template<class T>
Vector3<T>& Vector3< T >::operator/= ( const Vector3< T > &  rhs  )  [inline]

Division operator.

Parameters:
rhs Right hand side argument of binary operator.

References Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

template<class T>
template<class FromT >
Vector3<T> Vector3< T >::operator= ( const Vector3< FromT > &  rhs  )  [inline]

Copy casting operator.

Parameters:
rhs Right hand side argument of binary operator.

References Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

template<class T>
Vector3<T> Vector3< T >::operator= ( const Vector3< T > &  rhs  )  [inline]

Copy operator.

Parameters:
rhs Right hand side argument of binary operator.

References Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

template<class T>
bool Vector3< T >::operator== ( const Vector3< T > &  rhs  )  const [inline]

Equality test operator.

Parameters:
rhs Right hand side argument of binary operator.
Note:
Test of equality is based of threshold EPSILON value. To be two values equal, must satisfy this condition | lws.x - rhs.y | < EPSILON, same for y-coordinate, and z-coordinate.

References EPSILON, Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

template<class T>
T& Vector3< T >::operator[] ( int  n  )  [inline]

Array access operator.

Parameters:
n Array index
Returns:
For n = 0, reference to x coordinate, n = 1 reference to y, else reference to z y coordinate.

template<class T>
void Vector3< T >::rotate ( ax,
ay,
az 
) [inline]

Rotate vector around three axis.

Parameters:
ax Angle (in degrees) to be rotated around X-axis.
ay Angle (in degrees) to be rotated around Y-axis.
az Angle (in degrees) to be rotated around Z-axis.

References DEG2RAD.


Friends And Related Function Documentation

template<class T>
std::ostream& operator<< ( std::ostream &  lhs,
const Vector3< T >  rhs 
) [friend]

Output to stream operator.

Parameters:
lhs Left hand side argument of operator (commonly ostream instance).
rhs Right hand side argument of operator.
Returns:
Left hand side argument - the ostream object passed to operator.


Member Data Documentation

union { ... }

union { ... }

union { ... }

template<class T>
T Vector3< T >::b

Third element of vector, alias for B-coordinate.

For color notation.

template<class T>
T Vector3< T >::g

Second element of vector, alias for G-coordinate.

For color notation.

template<class T>
T Vector3< T >::r

First element of vector, alias for R-coordinate.

For color notation.

template<class T>
T Vector3< T >::s

First element of vector, alias for S-coordinate.

For textures notation.

template<class T>
T Vector3< T >::t

Second element of vector, alias for T-coordinate.

For textures notation.

template<class T>
T Vector3< T >::u

Third element of vector, alias for U-coordinate.

For textures notation.

template<class T>
T Vector3< T >::x

template<class T>
T Vector3< T >::y

template<class T>
T Vector3< T >::z


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

Generated on Mon Nov 9 21:47:51 2009 for vmath by  doxygen 1.5.8