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.
T Norm () const
 Returns the norm of this vector.
void Normalize ()
 Scale this vector to length = 1.0;.
csVector4T & operator *= (T f)
 Multiply this vector by a scalar.
csVector4T operator+ () const
 Unary + operator.
csVector4T & operator+= (const csVector4T &v)
 Add another vector to this vector.
csVector4T operator- () const
 Unary - operator.
csVector4T & operator-= (const csVector4T &v)
 Subtract another vector from this vector.
csVector4T & operator/= (T f)
 Divide this vector by a scalar.
template<typename T2>
csVector4T & operator= (const csVector4T< T2 > &other)
 Assignment operator.
float & operator[] (int n)
 Returns n-th component of the vector.
float operator[] (int 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.
T 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 72 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 79 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 82 of file vector4.h.

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

Copy Constructor.

Definition at line 87 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 90 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 139 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 104 of file vector4.h.

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

Get the value of this vector.

Definition at line 261 of file vector4.h.

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

Query if the vector is zero.

Definition at line 295 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 278 of file vector4.h.

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

Returns the norm of this vector.

Definition at line 264 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 284 of file vector4.h.

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

Multiply this vector by a scalar.

Definition at line 234 of file vector4.h.

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

Unary + operator.

Definition at line 242 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 212 of file vector4.h.

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

Unary - operator.

Definition at line 245 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 223 of file vector4.h.

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

Divide this vector by a scalar.

Definition at line 238 of file vector4.h.

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

Assignment operator.

Definition at line 94 of file vector4.h.

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

Returns n-th component of the vector.

Definition at line 208 of file vector4.h.

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

Returns n-th component of the vector.

Definition at line 200 of file vector4.h.

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

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

Definition at line 258 of file vector4.h.

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

Set the value of this vector.

Definition at line 255 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 252 of file vector4.h.

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

Set the value of this vector.

Definition at line 248 of file vector4.h.

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

Return the squared norm (magnitude) of this vector.

Definition at line 267 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 281 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 275 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 160 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 156 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 152 of file vector4.h.

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

Multiply a vector and a scalar.

Definition at line 148 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 123 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 176 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 128 of file vector4.h.

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

Add two vectors.

Definition at line 112 of file vector4.h.

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

Subtract two vectors.

Definition at line 117 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 168 of file vector4.h.

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

Divide a vector by a scalar.

Definition at line 164 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 188 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 184 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 172 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 192 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 180 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
 

The W component of the vector.

Definition at line 56 of file vector4.h.

Referenced by csVector4T< float >::Cross(), csVector4T< float >::Description(), csVector4T< float >::Get(), csVector4T< float >::IsZero(), csVector4T< float >::Norm(), csVector4T< float >::Normalize(), csVector4T< float >::operator *=(), csVector4T< float >::operator+=(), csVector4T< float >::operator-(), csVector4T< float >::operator-=(), csVector4T< float >::operator/=(), csVector4::operator=(), csVector4T< float >::operator=(), csVector4T< float >::Set(), csShaderVariable::SetValue(), and csVector4T< float >::SquaredNorm().

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

The X component of the vector.

Definition at line 50 of file vector4.h.

Referenced by csVector4T< float >::Cross(), csVector4T< float >::Description(), csVector4T< float >::Get(), csVector4T< float >::IsZero(), csVector4T< float >::Norm(), csVector4T< float >::Normalize(), csVector4T< float >::operator *=(), csVector4T< float >::operator+=(), csVector4T< float >::operator-(), csVector4T< float >::operator-=(), csVector4T< float >::operator/=(), csVector4::operator=(), csVector4T< float >::operator=(), csVector4T< float >::Set(), csShaderVariable::SetValue(), and csVector4T< float >::SquaredNorm().

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

The Y component of the vector.

Definition at line 52 of file vector4.h.

Referenced by csVector4T< float >::Cross(), csVector4T< float >::Description(), csVector4T< float >::Get(), csVector4T< float >::IsZero(), csVector4T< float >::Norm(), csVector4T< float >::Normalize(), csVector4T< float >::operator *=(), csVector4T< float >::operator+=(), csVector4T< float >::operator-(), csVector4T< float >::operator-=(), csVector4T< float >::operator/=(), csVector4::operator=(), csVector4T< float >::operator=(), csVector4T< float >::Set(), csShaderVariable::SetValue(), and csVector4T< float >::SquaredNorm().

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

The Z component of the vector.

Definition at line 54 of file vector4.h.

Referenced by csVector4T< float >::Cross(), csVector4T< float >::Description(), csVector4T< float >::Get(), csVector4T< float >::IsZero(), csVector4T< float >::Norm(), csVector4T< float >::Normalize(), csVector4T< float >::operator *=(), csVector4T< float >::operator+=(), csVector4T< float >::operator-(), csVector4T< float >::operator-=(), csVector4T< float >::operator/=(), csVector4::operator=(), csVector4T< float >::operator=(), csVector4T< float >::Set(), csShaderVariable::SetValue(), and csVector4T< float >::SquaredNorm().


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