CrystalSpace

Public API Reference

csVector4T< T > Class Template Reference
[Geometry utilities]

A 4D vector with variable type components. More...

#include <csgeom/vector4.h>

List of all members.

Public Member Functions

void Cross (const csVector4T &v1, const csVector4T &v2)
 Take cross product of two vectors and put result in this vector.
 csVector4T (const csVector3 &v)
 Convert from a three-component vector. w is set to 1.
 csVector4T (const csVector4T &v)
 Copy Constructor.
 csVector4T (const T &ix, const T &iy, const T &iz=T(0), const T &iw=T(1))
 Make a new vector and initialize with the given values.
 csVector4T (const T &m)
 Make a new initialized vector.
 csVector4T ()
 Make a new vector.
csString Description () const
 Return a textual representation of the vector in the form "x,y,z,w".
void Get (T *v)
 Get the value of this vector.
bool IsZero (T precision=SMALL_EPSILON) const
 Query if the vector is zero.
Norm () const
 Returns the norm of this vector.
void Normalize ()
 Scale this vector to length = 1.0;.
csVector4Toperator *= (T f)
 Multiply this vector by a scalar.
csVector4T operator+ () const
 Unary + operator.
csVector4Toperator+= (const csVector4T &v)
 Add another vector to this vector.
csVector4T operator- () const
 Unary - operator.
csVector4Toperator-= (const csVector4T &v)
 Subtract another vector from this vector.
csVector4Toperator/= (T f)
 Divide this vector by a scalar.
template<typename T2>
csVector4Toperator= (const csVector4T< T2 > &other)
 Assignment operator.
float & operator[] (size_t n)
 Returns n-th component of the vector.
float operator[] (size_t n) const
 Returns n-th component of the vector.
void Set (T v)
 Set the value of this vector so that all components are the same.
void Set (T const *v)
 Set the value of this vector.
void Set (csVector4T const &v)
 Set the value of this vector.
void Set (T sx, T sy, T sz, T sw)
 Set the value of this vector.
SquaredNorm () const
 Return the squared norm (magnitude) of this vector.
csVector4T Unit () const
 Returns the unit vector in the direction of this vector.

Static Public Member Functions

static T Norm (const csVector4T &v)
 Returns the norm (magnitude) of a vector.
static csVector4T Unit (const csVector4T &v)
 Normalizes a vector to a unit vector.

Friends

csVector4T operator * (int f, const csVector4T &v)
 Multiply a vector and a scalar int.
csVector4T operator * (const csVector4T &v, int f)
 Multiply a vector and a scalar int.
csVector4T operator * (float f, const csVector4T &v)
 Multiply a vector and a scalar.
csVector4T operator * (const csVector4T &v, T f)
 Multiply a vector and a scalar.
float operator * (const csVector4T &v1, const csVector4T &v2)
 Take the dot product of two vectors.
bool operator!= (const csVector4T &v1, const csVector4T &v2)
 Check if two vectors are not equal.
csVector4T operator% (const csVector4T &v1, const csVector4T &v2)
 Take the cross product of two vectors.
csVector4T operator+ (const csVector4T &v1, const csVector4T &v2)
 Add two vectors.
csVector4T operator- (const csVector4T &v1, const csVector4T &v2)
 Subtract two vectors.
csVector4T operator/ (const csVector4T &v, int f)
 Divide a vector by a scalar int.
csVector4T operator/ (const csVector4T &v, T f)
 Divide a vector by a scalar.
bool operator< (const csVector4T &v, float f)
 Test if each component of a vector is less than a small epsilon value.
csVector4T operator<< (const csVector4T &v1, const csVector4T &v2)
 Project one vector onto another.
bool operator== (const csVector4T &v1, const csVector4T &v2)
 Check if two vectors are equal.
bool operator> (float f, const csVector4T &v)
 Test if each component of a vector is less than a small epsilon value.
csVector4T operator>> (const csVector4T &v1, const csVector4T &v2)
 Project one vector onto another.


Detailed Description

template<typename T>
class csVector4T< T >

A 4D vector with variable type components.

Definition at line 40 of file vector4.h.


Constructor & Destructor Documentation

template<typename T>
csVector4T< T >::csVector4T (  )  [inline]

Make a new vector.

The vector is not initialized. This makes the code slightly faster.

Definition at line 73 of file vector4.h.

template<typename T>
csVector4T< T >::csVector4T ( const T &  m  )  [inline]

Make a new initialized vector.

Creates a new vector and initializes it to m*<1,1,1,1>. To create a vector initialized to the zero vector, use csVector4(0)

Definition at line 80 of file vector4.h.

template<typename T>
csVector4T< T >::csVector4T ( const T &  ix,
const T &  iy,
const T &  iz = T(0),
const T &  iw = T(1) 
) [inline]

Make a new vector and initialize with the given values.

Definition at line 83 of file vector4.h.

template<typename T>
csVector4T< T >::csVector4T ( const csVector4T< T > &  v  )  [inline]

Copy Constructor.

Definition at line 88 of file vector4.h.

template<typename T>
csVector4T< T >::csVector4T ( const csVector3 v  )  [inline]

Convert from a three-component vector. w is set to 1.

Definition at line 91 of file vector4.h.


Member Function Documentation

template<typename T>
void csVector4T< T >::Cross ( const csVector4T< T > &  v1,
const csVector4T< T > &  v2 
) [inline]

Take cross product of two vectors and put result in this vector.

Definition at line 140 of file vector4.h.

template<typename T>
csString csVector4T< T >::Description (  )  const [inline]

Return a textual representation of the vector in the form "x,y,z,w".

Definition at line 105 of file vector4.h.

template<typename T>
void csVector4T< T >::Get ( T *  v  )  [inline]

Get the value of this vector.

Definition at line 262 of file vector4.h.

template<typename T>
bool csVector4T< T >::IsZero ( precision = SMALL_EPSILON  )  const [inline]

Query if the vector is zero.

Definition at line 296 of file vector4.h.

template<typename T>
static T csVector4T< T >::Norm ( const csVector4T< T > &  v  )  [inline, static]

Returns the norm (magnitude) of a vector.

Definition at line 279 of file vector4.h.

template<typename T>
T csVector4T< T >::Norm (  )  const [inline]

Returns the norm of this vector.

Definition at line 265 of file vector4.h.

Referenced by csVector4T< float >::Norm(), and csVector4T< float >::Unit().

template<typename T>
void csVector4T< T >::Normalize (  )  [inline]

Scale this vector to length = 1.0;.

Definition at line 285 of file vector4.h.

template<typename T>
csVector4T& csVector4T< T >::operator *= ( f  )  [inline]

Multiply this vector by a scalar.

Definition at line 235 of file vector4.h.

template<typename T>
csVector4T csVector4T< T >::operator+ (  )  const [inline]

Unary + operator.

Definition at line 243 of file vector4.h.

template<typename T>
csVector4T& csVector4T< T >::operator+= ( const csVector4T< T > &  v  )  [inline]

Add another vector to this vector.

Definition at line 213 of file vector4.h.

template<typename T>
csVector4T csVector4T< T >::operator- (  )  const [inline]

Unary - operator.

Definition at line 246 of file vector4.h.

template<typename T>
csVector4T& csVector4T< T >::operator-= ( const csVector4T< T > &  v  )  [inline]

Subtract another vector from this vector.

Definition at line 224 of file vector4.h.

template<typename T>
csVector4T& csVector4T< T >::operator/= ( f  )  [inline]

Divide this vector by a scalar.

Definition at line 239 of file vector4.h.

template<typename T>
template<typename T2>
csVector4T& csVector4T< T >::operator= ( const csVector4T< T2 > &  other  )  [inline]

Assignment operator.

Definition at line 95 of file vector4.h.

template<typename T>
float& csVector4T< T >::operator[] ( size_t  n  )  [inline]

Returns n-th component of the vector.

Definition at line 209 of file vector4.h.

template<typename T>
float csVector4T< T >::operator[] ( size_t  n  )  const [inline]

Returns n-th component of the vector.

Definition at line 201 of file vector4.h.

template<typename T>
void csVector4T< T >::Set ( v  )  [inline]

Set the value of this vector so that all components are the same.

Definition at line 259 of file vector4.h.

template<typename T>
void csVector4T< T >::Set ( T const *  v  )  [inline]

Set the value of this vector.

Definition at line 256 of file vector4.h.

template<typename T>
void csVector4T< T >::Set ( csVector4T< T > const &  v  )  [inline]

Set the value of this vector.

Definition at line 253 of file vector4.h.

template<typename T>
void csVector4T< T >::Set ( sx,
sy,
sz,
sw 
) [inline]

Set the value of this vector.

Definition at line 249 of file vector4.h.

template<typename T>
T csVector4T< T >::SquaredNorm (  )  const [inline]

Return the squared norm (magnitude) of this vector.

Definition at line 268 of file vector4.h.

template<typename T>
static csVector4T csVector4T< T >::Unit ( const csVector4T< T > &  v  )  [inline, static]

Normalizes a vector to a unit vector.

Definition at line 282 of file vector4.h.

template<typename T>
csVector4T csVector4T< T >::Unit (  )  const [inline]

Returns the unit vector in the direction of this vector.

Attempting to normalize a zero-vector will result in a divide by zero error. This is as it should be... fix the calling code.

Definition at line 276 of file vector4.h.

Referenced by csVector4T< float >::Unit().


Friends And Related Function Documentation

template<typename T>
csVector4T operator * ( int  f,
const csVector4T< T > &  v 
) [friend]

Multiply a vector and a scalar int.

Definition at line 161 of file vector4.h.

template<typename T>
csVector4T operator * ( const csVector4T< T > &  v,
int  f 
) [friend]

Multiply a vector and a scalar int.

Definition at line 157 of file vector4.h.

template<typename T>
csVector4T operator * ( float  f,
const csVector4T< T > &  v 
) [friend]

Multiply a vector and a scalar.

Definition at line 153 of file vector4.h.

template<typename T>
csVector4T operator * ( const csVector4T< T > &  v,
f 
) [friend]

Multiply a vector and a scalar.

Definition at line 149 of file vector4.h.

template<typename T>
float operator * ( const csVector4T< T > &  v1,
const csVector4T< T > &  v2 
) [friend]

Take the dot product of two vectors.

Definition at line 124 of file vector4.h.

template<typename T>
bool operator!= ( const csVector4T< T > &  v1,
const csVector4T< T > &  v2 
) [friend]

Check if two vectors are not equal.

Definition at line 177 of file vector4.h.

template<typename T>
csVector4T operator% ( const csVector4T< T > &  v1,
const csVector4T< T > &  v2 
) [friend]

Take the cross product of two vectors.

Definition at line 129 of file vector4.h.

template<typename T>
csVector4T operator+ ( const csVector4T< T > &  v1,
const csVector4T< T > &  v2 
) [friend]

Add two vectors.

Definition at line 113 of file vector4.h.

template<typename T>
csVector4T operator- ( const csVector4T< T > &  v1,
const csVector4T< T > &  v2 
) [friend]

Subtract two vectors.

Definition at line 118 of file vector4.h.

template<typename T>
csVector4T operator/ ( const csVector4T< T > &  v,
int  f 
) [friend]

Divide a vector by a scalar int.

Definition at line 169 of file vector4.h.

template<typename T>
csVector4T operator/ ( const csVector4T< T > &  v,
f 
) [friend]

Divide a vector by a scalar.

Definition at line 165 of file vector4.h.

template<typename T>
bool operator< ( const csVector4T< T > &  v,
float  f 
) [friend]

Test if each component of a vector is less than a small epsilon value.

Definition at line 189 of file vector4.h.

template<typename T>
csVector4T operator<< ( const csVector4T< T > &  v1,
const csVector4T< T > &  v2 
) [friend]

Project one vector onto another.

Definition at line 185 of file vector4.h.

template<typename T>
bool operator== ( const csVector4T< T > &  v1,
const csVector4T< T > &  v2 
) [friend]

Check if two vectors are equal.

Definition at line 173 of file vector4.h.

template<typename T>
bool operator> ( float  f,
const csVector4T< T > &  v 
) [friend]

Test if each component of a vector is less than a small epsilon value.

Definition at line 193 of file vector4.h.

template<typename T>
csVector4T operator>> ( const csVector4T< T > &  v1,
const csVector4T< T > &  v2 
) [friend]

Project one vector onto another.

Definition at line 181 of file vector4.h.


Member Data Documentation

template<typename T>
T csVector4T< T >::m[4]

All components.

Definition at line 60 of file vector4.h.

Referenced by csVector4T< float >::operator[]().

template<typename T>
T csVector4T< T >::w

template<typename T>
T csVector4T< T >::x

template<typename T>
T csVector4T< T >::y

template<typename T>
T csVector4T< T >::z


The documentation for this class was generated from the following file:
Generated for Crystal Space by doxygen 1.4.7