Vector32 Struct Reference

#include <ge_vector.h>

Detailed Description

Represents a single precision vector.

Components

Float32 x
 
Float32 y
 
Float32 z
 

Constructors

 Vector32 ()
 
 Vector32 (Float32 ix, Float32 iy, Float32 iz)
 
 Vector32 (_DONTCONSTRUCT v)
 
 Vector32 (const Vector64 &v)
 
 Vector32 (Float32 in)
 

Get/Set Components

Float32operator[] (Int l)
 
const Float32operator[] (Int l) const
 

Math Operations

Bool IsZero () const
 
Bool IsNotZero () const
 
void SetZero ()
 
Bool IsEqual (const Vector32 &v2, const Float32 &epsilon=0.01f) const
 
Float32 GetAverage () const
 
Float32 GetSum () const
 
Float32 GetMin () const
 
Float32 GetMax () const
 
Vector32 Clamp01 () const
 
Float32 GetLength (void) const
 
Float32 GetSquaredLength (void) const
 
Vector32 GetNormalized (void) const
 
void Normalize (void)
 
Float32 GetAngle (const Vector32 &v1, const Vector32 &v2)
 
Float32 Dot (const Vector32 &v1, const Vector32 &v2)
 
Vector32 Cross (const Vector32 &v1, const Vector32 &v2)
 
Float32 Len (const Vector32 &v)
 

Operators

const Vector32operator+= (Float32 s)
 
const Vector32operator+= (const Vector32 &v)
 
const Vector32operator-= (Float32 s)
 
const Vector32operator-= (const Vector32 &v)
 
const Vector32operator*= (Float32 s)
 
const Vector32operator/= (Float32 s)
 
const Vector32operator*= (const Vector32 &v)
 
const Vector32 operator! (const Vector32 &v)
 
const Vector32 operator* (Float32 s, const Vector32 &v)
 
const Vector32 operator* (const Vector32 &v, Float32 s)
 
const Vector32 operator/ (const Vector32 &v, Float32 s)
 
const Vector32 operator* (const Vector32 &v1, const Vector32 &v2)
 
const Vector32 operator+ (Float32 s, const Vector32 &v)
 
const Vector32 operator+ (const Vector32 &v, Float32 s)
 
const Vector32 operator+ (const Vector32 &v1, const Vector32 &v2)
 
const Vector32 operator- (Float32 s, const Vector32 &v)
 
const Vector32 operator- (const Vector32 &v, Float32 s)
 
const Vector32 operator- (const Vector32 &v1, const Vector32 &v2)
 
const Vector32 operator- (const Vector32 &v)
 
Bool operator== (const Vector32 &v1, const Vector32 &v2)
 
Bool operator== (const Vector32 &v1, Float32 r)
 
Bool operator!= (const Vector32 &v1, Float32 r)
 
Bool operator!= (const Vector32 &v1, const Vector32 &v2)
 

Constructor & Destructor Documentation

§ Vector32() [1/5]

Vector32 ( )

Default constructor. Sets components to zero.

§ Vector32() [2/5]

Vector32 ( Float32  ix,
Float32  iy,
Float32  iz 
)
explicit

Constructs a vector with the given coordinates.

Parameters
[in]ixAssigned to x.
[in]iyAssigned to y.
[in]izAssigned to z.

§ Vector32() [3/5]

Vector32 ( _DONTCONSTRUCT  v)
explicit

Constructs an uninitialized vector.

Parameters
[in]vDummy argument. Pass DC.

§ Vector32() [4/5]

Vector32 ( const Vector64 v)
explicit

Constructs a single precision vector from a double precision vector.

Parameters
[in]vA double precision vector.

§ Vector32() [5/5]

Vector32 ( Float32  in)
explicit

Constructs a vector setting each component to the same in value.

Parameters
[in]inAssigned to x, y and z.

Member Function Documentation

§ operator[]() [1/2]

Float32& operator[] ( Int  l)

Sets a vector component.

Parameters
[in]lThe component index in the vector. 0 <= l < 2.
0 returns x, 1 returns y and 2 returns z.
Any other value must not be used and will crash.
Returns
The vector component to set.

§ operator[]() [2/2]

const Float32& operator[] ( Int  l) const

Gets a vector component.

Parameters
[in]lThe component index in the vector. 0 <= l < 2.
0 returns x, 1 returns y and 2 returns z.
Any other value must not be used and will crash.
Returns
The vector component to get.

§ IsZero()

Bool IsZero ( ) const

Checks if each component is zero.

Returns
true if each component is zero, otherwise false.

§ IsNotZero()

Bool IsNotZero ( ) const

Checks if one of the components is not zero.

Returns
true if one of the components is not zero, otherwise false.

§ SetZero()

void SetZero ( )

Sets all components to zero.

§ IsEqual()

Bool IsEqual ( const Vector32 v2,
const Float32 epsilon = 0.01f 
) const

Checks component-wise if the difference between the vector and vector v2 is no bigger than epsilon.

Parameters
[in]v2The other vector to compare against.
[in]epsilonThe epsilon value.
Returns
true if the difference is no bigger than epsilon, otherwise false.

§ GetAverage()

Float32 GetAverage ( ) const

Calculates the average value of x, y and z components.

Returns
The average value of the vector components.

§ GetSum()

Float32 GetSum ( ) const

Calculates the sum of x, y and z components.

Returns
The sum of the vector components.

§ GetMin()

Float32 GetMin ( void  ) const

Gets the minimum of x, y and z components.

Returns
The minimum of the vector components.

§ GetMax()

Float32 GetMax ( void  ) const

Gets the maximum of x, y and z components.

Returns
The maximum of the vector components.

§ Clamp01()

Vector32 Clamp01 ( ) const

Gets the vector clamped to the range [0.0 .. 1.0].

Returns
The vector clamped to the range [0.0 .. 1.0].

§ GetLength()

Float32 GetLength ( void  ) const

Calculates the length of the vector.

See also
Len()
Returns
The length of the vector.

§ GetSquaredLength()

Float32 GetSquaredLength ( void  ) const

Calculates the squared length of the vector.

Returns
The squared length of the vector.

§ GetNormalized()

Vector32 GetNormalized ( void  ) const

Calculates the normalized vector, so that GetLength()==1.0.

See also
operator!()
Returns
The normalized vector.

§ Normalize()

void Normalize ( void  )

Normalizes the vector, so that GetLength()==1.0.

§ operator+=() [1/2]

const Vector32& operator+= ( Float32  s)

Adds scalar s to each vector component.

Parameters
[in]sThe scalar to add.
Returns
This vector.

§ operator+=() [2/2]

const Vector32& operator+= ( const Vector32 v)

Adds the vector and vector v.

Parameters
[in]vThe vector to add.
Returns
This vector.

§ operator-=() [1/2]

const Vector32& operator-= ( Float32  s)

Subtracts scalar s from each vector component.

Parameters
[in]sThe scalar to subtract.
Returns
This vector.

§ operator-=() [2/2]

const Vector32& operator-= ( const Vector32 v)

Subtracts vector v from the vector.

Parameters
[in]vThe vector to subtract.
Returns
This vector.

§ operator*=() [1/2]

const Vector32& operator*= ( Float32  s)

Multiplies each vector component by scalar s.

Parameters
[in]sThe scalar to multiply.
Returns
This vector.

§ operator/=()

const Vector32& operator/= ( Float32  s)

Divides each vector component by scalar s.

Parameters
[in]sThe dividing scalar.
Returns
This vector.

§ operator*=() [2/2]

const Vector32& operator*= ( const Vector32 v)

Multiplies the vector component-wise by vector v.

Parameters
[in]vThe vector to multiply.
Returns
This vector.

Friends And Related Function Documentation

§ GetAngle

Float32 GetAngle ( const Vector32 v1,
const Vector32 v2 
)
friend

Calculates the angle (in radians) between v1 and v2.

Parameters
[in]v1The first vector.
[in]v2The second vector.
Returns
The angle between v1 and v2.

§ Dot

Float32 Dot ( const Vector32 v1,
const Vector32 v2 
)
friend

Calculates the dot product of vectors v1 and v2.

Parameters
[in]v1The first vector.
[in]v2The second vector.
Returns
The dot product of v1 and v2.

§ Cross

Vector32 Cross ( const Vector32 v1,
const Vector32 v2 
)
friend

Calculates the cross product of vectors v1 and v2.

Parameters
[in]v1The first vector.
[in]v2The second vector.
Returns
The cross product of v1 and v2.

§ Len

Float32 Len ( const Vector32 v)
friend

Calculates the length of vector v.

See also
GetLength()
Parameters
[in]vThe vector.
Returns
The length of the vector.

§ operator!

const Vector32 operator! ( const Vector32 v)
friend

Calculates the normalized vector v.

See also
GetNormalized()
Parameters
[in]vThe vector.
Returns
The normalized vector.

§ operator* [1/3]

const Vector32 operator* ( Float32  s,
const Vector32 v 
)
friend

Multiplies each component of vector v by scalar s.

Parameters
[in]sThe scalar.
[in]vThe vector.
Returns
The scaled vector.

§ operator* [2/3]

const Vector32 operator* ( const Vector32 v,
Float32  s 
)
friend

Multiplies each component of vector v by scalar s.

Parameters
[in]vThe vector.
[in]sThe scalar.
Returns
The scaled vector.

§ operator/

const Vector32 operator/ ( const Vector32 v,
Float32  s 
)
friend

Divides each component of vector v by scalar s.

Parameters
[in]vThe vector.
[in]sThe scalar.
Returns
The scaled vector.

§ operator* [3/3]

const Vector32 operator* ( const Vector32 v1,
const Vector32 v2 
)
friend

Multiplies vectors v1 and v2 component-wise.

Parameters
[in]v1The first vector.
[in]v2The second vector.
Returns
The result of the vectors multiplication.

§ operator+ [1/3]

const Vector32 operator+ ( Float32  s,
const Vector32 v 
)
friend

Adds scalar s to each component of vector v.

Parameters
[in]sThe scalar.
[in]vThe vector.
Returns
The result vector.

§ operator+ [2/3]

const Vector32 operator+ ( const Vector32 v,
Float32  s 
)
friend

Adds scalar s to each component of vector v.

Parameters
[in]vThe vector.
[in]sThe scalar.
Returns
The result vector.

§ operator+ [3/3]

const Vector32 operator+ ( const Vector32 v1,
const Vector32 v2 
)
friend

Adds vectors v1 and v2 component-wise.

Parameters
[in]v1The first vector.
[in]v2The second vector.
Returns
The result of the vectors sum.

§ operator- [1/4]

const Vector32 operator- ( Float32  s,
const Vector32 v 
)
friend

Subtracts each component of vector v from scalar s.

Parameters
[in]sThe scalar.
[in]vThe vector.
Returns
The result vector.

§ operator- [2/4]

const Vector32 operator- ( const Vector32 v,
Float32  s 
)
friend

Subtracts scalar s from each component of vector v.

Parameters
[in]vThe vector.
[in]sThe scalar.
Returns
The result vector.

§ operator- [3/4]

const Vector32 operator- ( const Vector32 v1,
const Vector32 v2 
)
friend

Subtracts vector v1 and v2 component-wise.

Parameters
[in]v1The first vector.
[in]v2The second vector.
Returns
The result of the vectors subtraction.

§ operator- [4/4]

const Vector32 operator- ( const Vector32 v)
friend

Gets the negative of vector v.

Parameters
[in]vThe vector.
Returns
The negative vector.

§ operator== [1/2]

Bool operator== ( const Vector32 v1,
const Vector32 v2 
)
friend

Checks if vectors v1 and v2 are equal component-wise.

Parameters
[in]v1The first vector.
[in]v2The second vector.
Returns
true if the vectors are equal, otherwise false.

§ operator== [2/2]

Bool operator== ( const Vector32 v1,
Float32  r 
)
friend

Checks if each component of vector v1 is equal to scalar r.

Parameters
[in]v1The vector.
[in]rThe scalar.
Returns
true if the components are all equal to the scalar, otherwise false.

§ operator!= [1/2]

Bool operator!= ( const Vector32 v1,
Float32  r 
)
friend

Checks if any component of vector v1 is different to scalar r.

Parameters
[in]v1The vector.
[in]rThe scalar.
Returns
true if any component is different to the scalar, otherwise false.

§ operator!= [2/2]

Bool operator!= ( const Vector32 v1,
const Vector32 v2 
)
friend

Checks if vectors v1 and v2 are not equal component-wise.

Parameters
[in]v1The first vector.
[in]v2The second vector.
Returns
true if the vectors are not equal, otherwise false.

Member Data Documentation

§ x

X component.

§ y

Y component.

§ z

Z component.