Drag[en]gine Game Engine  1.0
decVector Class Reference

3 Component Vector. More...

#include <decVector.h>

Public Member Functions

Constructors and Destructors
 decVector ()
 
 decVector (float nx, float ny, float nz)
 
 decVector (const decVector &v)
 
 decVector (const decDVector &v)
 
 decVector (const decPoint3 &p)
 
Management
float Length () const
 
float LengthSquared () const
 
void Normalize ()
 
const decVector Normalized () const
 
const decVector Absolute () const
 Retrieves absolute vector. More...
 
void Snap (float grid)
 
bool IsEqualTo (const decVector &v, float threshold=VECTOR_THRESHOLD) const
 
bool IsZero (float threshold=VECTOR_THRESHOLD) const
 All components are equal to zero with respect to a threshold. More...
 
void SetZero ()
 
void Set (float nx, float ny, float nz)
 
void Set (const decVector &v)
 
void Negate ()
 
void SetSmallest (const decVector &v)
 Set each component to the smallest value of this vector and another vector. More...
 
decVector Smallest (const decVector &v) const
 Retrieve vector with each component set to the smallest value of this vector and another vector. More...
 
void SetLargest (const decVector &v)
 Set each component to the largest value of this vector and another vector. More...
 
decVector Largest (const decVector &v) const
 Retrieve vector with each component set to the largest value of this vector and another vector. More...
 
void SetClamped (const decVector &minValue, const decVector &maxValue)
 Clamp each component to the provided range. More...
 
decVector Clamped (const decVector &minValue, const decVector &maxValue) const
 Retrieves vector with each component clamped to the provided range. More...
 
decPoint3 Round () const
 Convert to point rounding to the nearest integer value. More...
 
Operators
decVector operator- () const
 
decVectoroperator= (const decVector &v)
 
decVectoroperator+= (const decVector &v)
 
decVectoroperator-= (const decVector &v)
 
decVectoroperator*= (float k)
 
decVectoroperator/= (float k)
 
decVector operator+ (const decVector &v) const
 
decVector operator- (const decVector &v) const
 
decVector operator* (float k) const
 
float operator* (const decVector &v) const
 
decVector operator/ (float k) const
 
decVector operator% (const decVector &v) const
 Retrieves a new vector with the cross product of this vector with another one. More...
 
bool operator< (const decVector &v) const
 
bool operator> (const decVector &v) const
 
bool operator<= (const decVector &v) const
 
bool operator>= (const decVector &v) const
 

Public Attributes

float x
 
float y
 
float z
 

Detailed Description

3 Component Vector.

Author
Pl├╝ss Roland
Version
1.0
Date
2014

Constructor & Destructor Documentation

◆ decVector() [1/5]

decVector::decVector ( )

Creates a new vector initialized to ( 0,0,0 ).

◆ decVector() [2/5]

decVector::decVector ( float  nx,
float  ny,
float  nz 
)

Creates a new vector with the given values.

◆ decVector() [3/5]

decVector::decVector ( const decVector v)

Creates a copy of a vector.

◆ decVector() [4/5]

decVector::decVector ( const decDVector v)

Creates a copy of a double vector.

◆ decVector() [5/5]

decVector::decVector ( const decPoint3 p)

Creates a copy of a double vector.

Member Function Documentation

◆ Absolute()

const decVector decVector::Absolute ( ) const

Retrieves absolute vector.

◆ Clamped()

decVector decVector::Clamped ( const decVector minValue,
const decVector maxValue 
) const

Retrieves vector with each component clamped to the provided range.

◆ IsEqualTo()

bool decVector::IsEqualTo ( const decVector v,
float  threshold = VECTOR_THRESHOLD 
) const

Determines if the components of this vector are equal to another one with respect to a threshold.

◆ IsZero()

bool decVector::IsZero ( float  threshold = VECTOR_THRESHOLD) const

All components are equal to zero with respect to a threshold.

◆ Largest()

decVector decVector::Largest ( const decVector v) const

Retrieve vector with each component set to the largest value of this vector and another vector.

◆ Length()

float decVector::Length ( ) const

Retrieves the length of the vector.

◆ LengthSquared()

float decVector::LengthSquared ( ) const

Retrieves the squared length of the vector.

◆ Negate()

void decVector::Negate ( )

Negates the vector.

◆ Normalize()

void decVector::Normalize ( )

Normalizes the vector. If the length of the vector is 0 an exception is thrown.

◆ Normalized()

const decVector decVector::Normalized ( ) const

Retrieves normalized vector. If the length of the vector is 0 an exception is thrown.

◆ operator%()

decVector decVector::operator% ( const decVector v) const

Retrieves a new vector with the cross product of this vector with another one.

The length of the result vector is len(a)*len(b)*cos(alpha). Hence the length of the result vector is only 1 if both vertices are of length 1 and orthogonal to each other.

◆ operator*() [1/2]

decVector decVector::operator* ( float  k) const

Retrieves a new vector with this vector scaled by k.

◆ operator*() [2/2]

float decVector::operator* ( const decVector v) const

Calculates the dot product of this vector with another one.

◆ operator*=()

decVector& decVector::operator*= ( float  k)

Multiplies the components of this vector with a value k.

◆ operator+()

decVector decVector::operator+ ( const decVector v) const

Retrieves a new vector with the sum of this vector with another one.

◆ operator+=()

decVector& decVector::operator+= ( const decVector v)

Adds the components of another vector to this one.

◆ operator-() [1/2]

decVector decVector::operator- ( ) const

Retrieves the negation of this vector.

◆ operator-() [2/2]

decVector decVector::operator- ( const decVector v) const

Retrieves a new vector with the difference of this vector to another one.

◆ operator-=()

decVector& decVector::operator-= ( const decVector v)

Subtracts the components of another vector from this vector.

◆ operator/()

decVector decVector::operator/ ( float  k) const

Retrieves a new vector with this vector divided by k. If k is 0 an exception is thrown.

◆ operator/=()

decVector& decVector::operator/= ( float  k)

Divides the components of this vector by a value k. If the value k is 0 an exception is thrown.

◆ operator<()

bool decVector::operator< ( const decVector v) const

Determines if all the components of this vector are less then the components of another one.

◆ operator<=()

bool decVector::operator<= ( const decVector v) const

Determines if all the components of this vector are less then or equal to the components of another one.

◆ operator=()

decVector& decVector::operator= ( const decVector v)

Sets the components of this vector to the values of another one.

◆ operator>()

bool decVector::operator> ( const decVector v) const

Determines if all the components of this vector are greater then the components of another one.

◆ operator>=()

bool decVector::operator>= ( const decVector v) const

Determines if all the components of this vector are greater then or equal to the components of another one.

◆ Round()

decPoint3 decVector::Round ( ) const

Convert to point rounding to the nearest integer value.

◆ Set() [1/2]

void decVector::Set ( float  nx,
float  ny,
float  nz 
)

Sets the components to the given values.

◆ Set() [2/2]

void decVector::Set ( const decVector v)

Sets the components to the given vector.

◆ SetClamped()

void decVector::SetClamped ( const decVector minValue,
const decVector maxValue 
)

Clamp each component to the provided range.

◆ SetLargest()

void decVector::SetLargest ( const decVector v)

Set each component to the largest value of this vector and another vector.

◆ SetSmallest()

void decVector::SetSmallest ( const decVector v)

Set each component to the smallest value of this vector and another vector.

◆ SetZero()

void decVector::SetZero ( )

Sets all components to 0.

◆ Smallest()

decVector decVector::Smallest ( const decVector v) const

Retrieve vector with each component set to the smallest value of this vector and another vector.

◆ Snap()

void decVector::Snap ( float  grid)

Snaps the components of the vector to a grid with the given size.

Member Data Documentation

◆ x

float decVector::x

X Component of vector.

Referenced by decCollisionBox::ProjectExtends().

◆ y

float decVector::y

Y Component of vector.

Referenced by decCollisionBox::ProjectExtends().

◆ z

float decVector::z

Z Component of vector.

Referenced by decCollisionBox::ProjectExtends().


The documentation for this class was generated from the following file: