Vector3 Class Reference

Description

A three dimensional vector.

Methods

 Vector3 (BS_ZERO zero)
 
 Vector3 (float x, float y, float z)
 
 Vector3 (const Vector4 &vec)
 
void swap (Vector3 &other)
 Exchange the contents of this vector with another. More...
 
float operator[] (UINT32 i) const
 
float & operator[] (UINT32 i)
 
float * ptr ()
 Pointer accessor for direct copying. More...
 
const float * ptr () const
 Pointer accessor for direct copying. More...
 
Vector3operator= (const Vector3 &rhs)
 
Vector3operator= (float rhs)
 
bool operator== (const Vector3 &rhs) const
 
bool operator!= (const Vector3 &rhs) const
 
Vector3 operator+ (const Vector3 &rhs) const
 
Vector3 operator- (const Vector3 &rhs) const
 
Vector3 operator* (float rhs) const
 
Vector3 operator* (const Vector3 &rhs) const
 
Vector3 operator/ (float val) const
 
Vector3 operator/ (const Vector3 &rhs) const
 
const Vector3operator+ () const
 
Vector3 operator- () const
 
Vector3operator+= (const Vector3 &rhs)
 
Vector3operator+= (float rhs)
 
Vector3operator-= (const Vector3 &rhs)
 
Vector3operator-= (float rhs)
 
Vector3operator*= (float rhs)
 
Vector3operator*= (const Vector3 &rhs)
 
Vector3operator/= (float rhs)
 
Vector3operator/= (const Vector3 &rhs)
 
float length () const
 Returns the length (magnitude) of the vector. More...
 
float squaredLength () const
 Returns the square of the length(magnitude) of the vector. More...
 
float distance (const Vector3 &rhs) const
 Returns the distance to another vector. More...
 
float squaredDistance (const Vector3 &rhs) const
 Returns the square of the distance to another vector. More...
 
float dot (const Vector3 &vec) const
 Calculates the dot (scalar) product of this vector with another. More...
 
float normalize ()
 Normalizes the vector. More...
 
Vector3 cross (const Vector3 &other) const
 Calculates the cross-product of 2 vectors, that is, the vector that lies perpendicular to them both. More...
 
void floor (const Vector3 &cmp)
 Sets this vector's components to the minimum of its own and the ones of the passed in vector. More...
 
void ceil (const Vector3 &cmp)
 Sets this vector's components to the maximum of its own and the ones of the passed in vector. More...
 
Vector3 perpendicular () const
 Generates a vector perpendicular to this vector. More...
 
Radian angleBetween (const Vector3 &dest) const
 Gets the angle between 2 vectors. More...
 
bool isZeroLength () const
 Returns true if this vector is zero length. More...
 
Vector3 reflect (const Vector3 &normal) const
 Calculates a reflection vector to the plane with the given normal. More...
 
void orthogonalComplement (Vector3 &a, Vector3 &b)
 Calculates two vectors orthonormal to the current vector, and normalizes the current vector if not already. More...
 
bool isNaN () const
 Checks are any of the vector components not a number. More...
 

Static methods

static void orthonormalize (Vector3 &vec0, Vector3 &vec1, Vector3 &vec2)
 Performs Gram-Schmidt orthonormalization. More...
 
static float dot (const Vector3 &a, const Vector3 &b)
 Calculates the dot (scalar) product of two vectors. More...
 
static Vector3 normalize (const Vector3 &val)
 Normalizes the provided vector and returns a new normalized instance. More...
 
static Vector3 cross (const Vector3 &a, const Vector3 &b)
 Calculates the cross-product of 2 vectors, that is, the vector that lies perpendicular to them both. More...
 
static Vector3 lerp (float t, const Vector3 &a, const Vector3 &b)
 Linearly interpolates between the two vectors using t. More...
 
static Vector3 min (const Vector3 &a, const Vector3 &b)
 Returns the minimum of all the vector components as a new vector. More...
 
static Vector3 max (const Vector3 &a, const Vector3 &b)
 Returns the maximum of all the vector components as a new vector. More...
 

Fields

float x
 
float y
 
float z
 

Static fields

static const Vector3 ZERO
 
static const Vector3 ONE
 
static const Vector3 INF
 
static const Vector3 UNIT_X
 
static const Vector3 UNIT_Y
 
static const Vector3 UNIT_Z
 

Method documentation

Radian angleBetween ( const Vector3 dest) const

Gets the angle between 2 vectors.

void ceil ( const Vector3 cmp)

Sets this vector's components to the maximum of its own and the ones of the passed in vector.

Vector3 cross ( const Vector3 other) const

Calculates the cross-product of 2 vectors, that is, the vector that lies perpendicular to them both.

static Vector3 cross ( const Vector3 a,
const Vector3 b 
)
static

Calculates the cross-product of 2 vectors, that is, the vector that lies perpendicular to them both.

float distance ( const Vector3 rhs) const

Returns the distance to another vector.

float dot ( const Vector3 vec) const

Calculates the dot (scalar) product of this vector with another.

static float dot ( const Vector3 a,
const Vector3 b 
)
static

Calculates the dot (scalar) product of two vectors.

void floor ( const Vector3 cmp)

Sets this vector's components to the minimum of its own and the ones of the passed in vector.

bool isNaN ( ) const

Checks are any of the vector components not a number.

bool isZeroLength ( ) const

Returns true if this vector is zero length.

float length ( ) const

Returns the length (magnitude) of the vector.

static Vector3 lerp ( float  t,
const Vector3 a,
const Vector3 b 
)
static

Linearly interpolates between the two vectors using t.

t should be in [0, 1] range, where t = 0 corresponds to the left vector, while t = 1 corresponds to the right vector.

static Vector3 max ( const Vector3 a,
const Vector3 b 
)
static

Returns the maximum of all the vector components as a new vector.

static Vector3 min ( const Vector3 a,
const Vector3 b 
)
static

Returns the minimum of all the vector components as a new vector.

float normalize ( )

Normalizes the vector.

static Vector3 normalize ( const Vector3 val)
static

Normalizes the provided vector and returns a new normalized instance.

void orthogonalComplement ( Vector3 a,
Vector3 b 
)

Calculates two vectors orthonormal to the current vector, and normalizes the current vector if not already.

static void orthonormalize ( Vector3 vec0,
Vector3 vec1,
Vector3 vec2 
)
static

Performs Gram-Schmidt orthonormalization.

Vector3 perpendicular ( ) const

Generates a vector perpendicular to this vector.

float* ptr ( )

Pointer accessor for direct copying.

const float* ptr ( ) const

Pointer accessor for direct copying.

Vector3 reflect ( const Vector3 normal) const

Calculates a reflection vector to the plane with the given normal.

float squaredDistance ( const Vector3 rhs) const

Returns the square of the distance to another vector.

float squaredLength ( ) const

Returns the square of the length(magnitude) of the vector.

void swap ( Vector3 other)

Exchange the contents of this vector with another.