LinearAlgebra
 All Classes Namespaces Files Functions Variables Typedefs Macros
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
a3d::Vector3< T, M > Struct Template Reference

A vector of three values for 3d calculations. More...

Collaboration diagram for a3d::Vector3< T, M >:
Collaboration graph
[legend]

Public Member Functions

 Vector3 ()
 Creates an uninitialized vector. More...
 
 Vector3 (T x, T y, T z)
 Creates a vector with the specified values. More...
 
template<class T2 , class M2 >
 Vector3 (const Vector3< T2, M2 > &x)
 Copies the specified vector. More...
 
 Vector3 (const float *va)
 Copies a float array vector. More...
 
 Vector3 (int i)
 Creates a vector initialized to zero. More...
 
template<class T2 , class M2 >
 Vector3 (const Vector4< T2, M2 > &x)
 Cast from homogenious coordinates. More...
 
Vector3< T, M > & operator= (const Vector3< T, M > &o)
 Copy operator. More...
 
template<class T2 , class M2 >
Vector3< T, M > & operator= (const Vector3< T2, M2 > &o)
 Copy operator. More...
 
Vector3< T, M > & operator= (const float *va)
 Copies a float array vector. More...
 
Vector3< T, M > operator- () const
 Negates the vector. More...
 
Vector3< T, M > normalized () const
 Returns a normalized version of this vector. More...
 
Vector3< T, M > hsv2rgb () const
 This function treats this vector as a HSV space color vector and returns it transformed to RGB color space. More...
 
Vector3< T, M > rgb2hsv () const
 This function treats this vector as a RGB space color vector and returns it transformed to HSV color space. More...
 
length () const
 Returns the length of this vector. More...
 
length2 () const
 Returns the square length of this vector. More...
 
 operator const T * () const
 Casts this vector to an array representation. More...
 
 operator T * ()
 Casts this vector to an array representation. More...
 
const T & operator() (int i) const
 Index operator. More...
 
const T & operator[] (int i) const
 Index operator. More...
 
T & operator() (int i)
 Index operator. More...
 
T & operator[] (int i)
 Index operator. More...
 
template<class S >
bool fromScreenPosition (S sx, S sy, a3d::Vector3< T, M > &x, a3d::Vector3< T, M > &v)
 

Static Public Member Functions

template<class S >
static bool fromScreenPosition (S sx, S sy, Vector3< T, M > &x, Vector3< T, M > &v)
 If this is called in an OpenGL context it will find the 3D equivalent of the specified screen position and the vector that points straight in at that position. More...
 

Public Attributes

v [3]
 

Detailed Description

template<class T, class M = Math<T>>
struct a3d::Vector3< T, M >

A vector of three values for 3d calculations.

Constructor & Destructor Documentation

template<class T, class M = Math<T>>
a3d::Vector3< T, M >::Vector3 ( )
inline

Creates an uninitialized vector.

template<class T, class M = Math<T>>
a3d::Vector3< T, M >::Vector3 ( x,
y,
z 
)
inline

Creates a vector with the specified values.

References a3d::Vector3< T, M >::v.

template<class T, class M = Math<T>>
template<class T2 , class M2 >
a3d::Vector3< T, M >::Vector3 ( const Vector3< T2, M2 > &  x)
inline

Copies the specified vector.

References a3d::Vector3< T, M >::v.

template<class T, class M = Math<T>>
a3d::Vector3< T, M >::Vector3 ( const float *  va)
inline

Copies a float array vector.

References a3d::Vector3< T, M >::v.

template<class T, class M = Math<T>>
a3d::Vector3< T, M >::Vector3 ( int  i)
inlineexplicit

Creates a vector initialized to zero.

References a3d::Vector3< T, M >::v.

template<class T, class M = Math<T>>
template<class T2 , class M2 >
a3d::Vector3< T, M >::Vector3 ( const Vector4< T2, M2 > &  x)
inlineexplicit

Cast from homogenious coordinates.

References a3d::Vector3< T, M >::v, and a3d::Vector4< T, M >::v.

Member Function Documentation

template<class T, class M = Math<T>>
template<class S >
static bool a3d::Vector3< T, M >::fromScreenPosition ( sx,
sy,
Vector3< T, M > &  x,
Vector3< T, M > &  v 
)
inlinestatic

If this is called in an OpenGL context it will find the 3D equivalent of the specified screen position and the vector that points straight in at that position.

Two values are given representing the 2D screen coordinate and two vectors in which the result will be inserted. The function will return true on success.

Parameters
sxscreen x coordinate in the range zero to screen width minus one
syscreen y coordinate in the range zero to screen height minus one.

This coordinate is usually defined upside down compared to the 3D system, but if it is not just negate the parameter and this function treats it as not upside down.

Parameters
xthe specified screen coordinate in 3D space
va unit vector pointing from eye to x position
Returns
true on successful estimation
template<class T, class M = Math<T>>
template<class S >
bool a3d::Vector3< T, M >::fromScreenPosition ( sx,
sy,
a3d::Vector3< T, M > &  x,
a3d::Vector3< T, M > &  v 
)

References a3d::Matrix4< T, M >::inverse().

Here is the call graph for this function:

template<class T , class M >
a3d::Vector3< T, M > a3d::Vector3< T, M >::hsv2rgb ( ) const
inline

This function treats this vector as a HSV space color vector and returns it transformed to RGB color space.

Referenced by a3d::Vector4< T, M >::hsv2rgb().

template<class T, class M = Math<T>>
T a3d::Vector3< T, M >::length ( ) const
inline
template<class T, class M = Math<T>>
T a3d::Vector3< T, M >::length2 ( ) const
inline

Returns the square length of this vector.

template<class T, class M = Math<T>>
Vector3<T,M> a3d::Vector3< T, M >::normalized ( ) const
inline

Returns a normalized version of this vector.

References a3d::Vector3< T, M >::length().

Referenced by a3d::Quaternion< T, M >::fromAnglePair().

Here is the call graph for this function:

template<class T, class M = Math<T>>
a3d::Vector3< T, M >::operator const T * ( ) const
inline

Casts this vector to an array representation.

This makes it possible to provide for example a float vector as an array argument in for example OpenGL.

Use like this:

Vector3f c = Vector3f::hsv2rgb( 0.5, 0.5, 0.5 );
glColor3fv( (float*)c );

References a3d::Vector3< T, M >::v.

template<class T, class M = Math<T>>
a3d::Vector3< T, M >::operator T * ( )
inline

Casts this vector to an array representation.

This makes it possible to provide for example a float vector as an array argument in for example OpenGL. Anything written in the returned array will end up in the vector.

Use like this:

Vector3f c = Vector3f::hsv2rgb( 0.5, 0.5, 0.5 );
glColor3fv( (float*)c );

References a3d::Vector3< T, M >::v.

template<class T, class M = Math<T>>
const T& a3d::Vector3< T, M >::operator() ( int  i) const
inline

Index operator.

Access element.

References a3d::Vector3< T, M >::v.

template<class T, class M = Math<T>>
T& a3d::Vector3< T, M >::operator() ( int  i)
inline

Index operator.

Access element.

References a3d::Vector3< T, M >::v.

template<class T, class M = Math<T>>
Vector3<T,M> a3d::Vector3< T, M >::operator- ( ) const
inline

Negates the vector.

References a3d::Vector3< T, M >::v.

template<class T, class M = Math<T>>
Vector3<T,M>& a3d::Vector3< T, M >::operator= ( const Vector3< T, M > &  o)
inline

Copy operator.

References a3d::Vector3< T, M >::v.

template<class T, class M = Math<T>>
template<class T2 , class M2 >
Vector3<T,M>& a3d::Vector3< T, M >::operator= ( const Vector3< T2, M2 > &  o)
inline

Copy operator.

References a3d::Vector3< T, M >::v.

template<class T, class M = Math<T>>
Vector3<T,M>& a3d::Vector3< T, M >::operator= ( const float *  va)
inline

Copies a float array vector.

References a3d::Vector3< T, M >::v.

template<class T, class M = Math<T>>
const T& a3d::Vector3< T, M >::operator[] ( int  i) const
inline

Index operator.

Access element.

References a3d::Vector3< T, M >::v.

template<class T, class M = Math<T>>
T& a3d::Vector3< T, M >::operator[] ( int  i)
inline

Index operator.

Access element.

References a3d::Vector3< T, M >::v.

template<class T , class Mth >
a3d::Vector3< T, Mth > a3d::Vector3< T, Mth >::rgb2hsv ( ) const
inline

This function treats this vector as a RGB space color vector and returns it transformed to HSV color space.

Referenced by a3d::Vector4< T, M >::rgb2hsv().

Member Data Documentation

template<class T, class M = Math<T>>
T a3d::Vector3< T, M >::v[3]