_Vector4< TYPE > Class Template Reference

#include <vector4.h>

Detailed Description

template<class TYPE>
class _Vector4< TYPE >

Generic four-element vector mathematics. Can be used with the four-by-four matrix class _Matrix4.

See also
Vector for the regular vector class.

Public Member Functions

 _Vector4 (_DONTCONSTRUCT dc)
 
 _Vector4 ()
 
 _Vector4 (TYPE xIn, TYPE yIn, TYPE zIn, TYPE wIn)
 
 _Vector4 (TYPE v)
 
 _Vector4 (const Vector32 &v)
 
 _Vector4 (const Vector32 &v, Float32 r)
 
 _Vector4 (const Vector64 &v)
 
 _Vector4 (const Vector64 &v, Float64 r)
 
void SetZero ()
 
const TYPE Dot (const _Vector4 &b)
 
void MakeVector3 ()
 
const _Vector4operator+= (const _Vector4 &a)
 
const _Vector4operator*= (const Float a)
 

Public Attributes

union {
   struct {
      TYPE   x
 
      TYPE   y
 
      TYPE   z
 
      TYPE   w
 
   } 
 
   TYPE   m_prElements [4]
 
}; 
 

Friends

const _Vector4 operator- (const _Vector4 &a, const _Vector4 &b)
 
const _Vector4 operator+ (const _Vector4 &a, const _Vector4 &b)
 
const _Vector4 operator^ (const _Vector4 &a, const _Vector4 &b)
 
const TYPE Dot (const _Vector4 &a, const _Vector4 &b)
 
const _Vector4 operator* (const _Vector4 &a, TYPE b)
 
const VectorGetVector3 (const _Vector4 &v)
 
Bool operator== (const _Vector4 &a, const _Vector4 &b)
 

Constructor & Destructor Documentation

§ _Vector4() [1/8]

_Vector4 ( _DONTCONSTRUCT  dc)
explicit

Creates an uninitialized vector.

Parameters
[in]dcDummy argument. Pass DC.

§ _Vector4() [2/8]

_Vector4 ( )

Default constructor. Creates a (0, 0, 0, 1) vector.

§ _Vector4() [3/8]

_Vector4 ( TYPE  xIn,
TYPE  yIn,
TYPE  zIn,
TYPE  wIn 
)

Creates a (x, y, z, w) vector.

Parameters
[in]xInThe X component of the vector.
[in]yInThe Y component of the vector.
[in]zInThe Z component of the vector.
[in]wInThe W component of the vector.

§ _Vector4() [4/8]

_Vector4 ( TYPE  v)
explicit

Creates a (v, v, v, v) vector.

Parameters
[in]vThe scalar value.

§ _Vector4() [5/8]

_Vector4 ( const Vector32 v)
explicit

Creates a (v.x, v.y, v.z, 1.0) vector.

Parameters
[in]vThe Vector32 value.

§ _Vector4() [6/8]

_Vector4 ( const Vector32 v,
Float32  r 
)
explicit

Creates a (v.x, v.y, v.z, r) vector.

Parameters
[in]vThe Vector32 value.
[in]rThe Float32 value.

§ _Vector4() [7/8]

_Vector4 ( const Vector64 v)
explicit

Creates a (v.x, v.y, v.z, 1.0) vector.

Parameters
[in]vThe Vector64 value.

§ _Vector4() [8/8]

_Vector4 ( const Vector64 v,
Float64  r 
)
explicit

Creates a (v.x, v.y, v.z, r) vector.

Parameters
[in]vThe Vector64 value.
[in]rThe Float64 value.

Member Function Documentation

§ SetZero()

void SetZero ( )

Sets all vector components to zero.

§ Dot()

const TYPE Dot ( const _Vector4< TYPE > &  b)

Calculates the dot product of the vector and vector b.

Parameters
[in]bThe other vector.
Returns
The dot product.

§ MakeVector3()

void MakeVector3 ( )

Normalizes the vector so that w is 1.

Note
w must not be 0.

§ operator+=()

const _Vector4& operator+= ( const _Vector4< TYPE > &  a)

Adds two vectors together and sets the left-hand vector to the result.

Parameters
[in]aThe right-hand vector.
Returns
The result of the vector addition assigned to the left-hand vector.

§ operator*=()

const _Vector4& operator*= ( const Float  a)

Multiplies each vector components by a scalar and set the vector to the result.

Parameters
[in]aThe right-hand scalar.
Returns
The result of the multiplication assigned to the left-hand vector.

Friends And Related Function Documentation

§ operator-

const _Vector4 operator- ( const _Vector4< TYPE > &  a,
const _Vector4< TYPE > &  b 
)
friend

Subtracts two vectors.

Parameters
[in]aThe first vector.
[in]bThe second vector.
Returns
The result of the vector subtraction.

§ operator+

const _Vector4 operator+ ( const _Vector4< TYPE > &  a,
const _Vector4< TYPE > &  b 
)
friend

Adds two vectors.

Parameters
[in]aThe first vector.
[in]bThe second vector.
Returns
The result of the vector addition.

§ operator^

const _Vector4 operator^ ( const _Vector4< TYPE > &  a,
const _Vector4< TYPE > &  b 
)
friend

Multiplies each vector component in the left-hand vector by its counterpart in the right-hand vector.

Parameters
[in]aThe first vector.
[in]bThe second vector.
Returns
The result of the multiplication.

§ Dot

const TYPE Dot ( const _Vector4< TYPE > &  a,
const _Vector4< TYPE > &  b 
)
friend

Calculates the dot product of two vectors.

Parameters
[in]aThe first vector.
[in]bThe second vector.
Returns
The result of the dot product.

§ operator*

const _Vector4 operator* ( const _Vector4< TYPE > &  a,
TYPE  b 
)
friend

Multiplies the vector by a scalar.

Parameters
[in]aThe vector.
[in]bThe scalar.
Returns
The result of the multiplication.

§ GetVector3

const Vector& GetVector3 ( const _Vector4< TYPE > &  v)
friend

Casts the _Vector4 to a Vector.

Parameters
[in]vThe vector to cast.
Returns
The _Vector4 casted to a Vector.

§ operator==

Bool operator== ( const _Vector4< TYPE > &  a,
const _Vector4< TYPE > &  b 
)
friend

Equality operator. Checks if the two vectors are equal.

Parameters
[in]aThe first vector.
[in]bThe second vector.
Returns
true if the 2 vectors are equal, otherwise false.

Member Data Documentation

§ x

TYPE x

X component of the vector.

§ y

TYPE y

Y component of the vector.

§ z

TYPE z

Z component of the vector.

§ w

TYPE w

W component of the vector.

§ m_prElements

TYPE m_prElements[4]

An array storing the x, y, z and w components.

§ @969

union { ... }