Drag[en]gine Game Engine  1.21
decVector Class Reference

3 Component Vector. More...

#include <decVector.h>

Public Member Functions

Constructors and Destructors
 decVector ()
 Create new vector initialized to ( 0,0,0 ). More...
 
 decVector (float nx, float ny, float nz)
 Create new vector with the given values. More...
 
 decVector (const decVector &v)
 Create copy of a vector. More...
 
 decVector (const decDVector &v)
 Create copy of a double vector. More...
 
 decVector (const decPoint3 &p)
 Create copy of a double vector. More...
 
Management
float Length () const
 Length of the vector. More...
 
float LengthSquared () const
 Squared length of the vector. More...
 
void Normalize ()
 Normalizes the vector. If the length of the vector is 0 an exception is thrown. More...
 
const decVector Normalized () const
 Retrieves normalized vector. If the length of the vector is 0 an exception is thrown. More...
 
const decVector Absolute () const
 Retrieves absolute vector. More...
 
void Snap (float grid)
 Snaps the components of the vector to a grid with the given size. More...
 
bool IsEqualTo (const decVector &v, float threshold=VECTOR_THRESHOLD) const
 Components of this vector are equal to another one with respect to a threshold. More...
 
bool IsZero (float threshold=VECTOR_THRESHOLD) const
 All components are equal to zero with respect to a threshold. More...
 
void SetZero ()
 Sets all components to 0. More...
 
void Set (float nx, float ny, float nz)
 Set components to the given values. More...
 
void Set (const decVector &v)
 Set components to the given vector. More...
 
void Negate ()
 Negates the vector. More...
 
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...
 
decVector Mix (const decVector &vector, float blendFactor) const
 Mix vectors component wise. More...
 
decVector Multiply (const decVector &vector) const
 Multiply component wise. More...
 
Operators
decVector operator- () const
 Negation of this vector. More...
 
decVectoroperator= (const decVector &v)
 Set components of this vector to the values of another one. More...
 
decVectoroperator+= (const decVector &v)
 Adds the components of another vector to this one. More...
 
decVectoroperator-= (const decVector &v)
 Subtracts the components of another vector from this vector. More...
 
decVectoroperator*= (float k)
 Multiplies the components of this vector with a value k. More...
 
decVectoroperator/= (float k)
 Divides the components of this vector by a value k. If the value k is 0 an exception is thrown. More...
 
decVector operator+ (const decVector &v) const
 Retrieves a new vector with the sum of this vector with another one. More...
 
decVector operator- (const decVector &v) const
 Retrieves a new vector with the difference of this vector to another one. More...
 
decVector operator* (float k) const
 Retrieves a new vector with this vector scaled by k. More...
 
float operator* (const decVector &v) const
 Calculates the dot product of this vector with another one. More...
 
decVector operator/ (float k) const
 Retrieves a new vector with this vector divided by k. If k is 0 an exception is thrown. More...
 
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
 Determines if all the components of this vector are less then the components of another one. More...
 
bool operator> (const decVector &v) const
 Determines if all the components of this vector are greater then the components of another one. More...
 
bool operator<= (const decVector &v) const
 Determines if all the components of this vector are less then or equal to the components of another one. More...
 
bool operator>= (const decVector &v) const
 Determines if all the components of this vector are greater then or equal to the components of another one. More...
 

Public Attributes

float x
 X Component of vector. More...
 
float y
 Y Component of vector. More...
 
float z
 Z Component of vector. More...
 

Detailed Description

3 Component Vector.

Constructor & Destructor Documentation

◆ decVector() [1/5]

decVector::decVector ( )

Create new vector initialized to ( 0,0,0 ).

◆ decVector() [2/5]

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

Create new vector with the given values.

◆ decVector() [3/5]

decVector::decVector ( const decVector v)

Create copy of a vector.

◆ decVector() [4/5]

decVector::decVector ( const decDVector v)

Create copy of a double vector.

◆ decVector() [5/5]

decVector::decVector ( const decPoint3 p)

Create 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

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

Length of the vector.

◆ LengthSquared()

float decVector::LengthSquared ( ) const

Squared length of the vector.

◆ Mix()

decVector decVector::Mix ( const decVector vector,
float  blendFactor 
) const

Mix vectors component wise.

◆ Multiply()

decVector decVector::Multiply ( const decVector vector) const

Multiply component wise.

◆ 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]

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

Calculates the dot product of this vector with another one.

◆ operator*() [2/2]

decVector decVector::operator* ( float  k) const

Retrieves a new vector with this vector scaled by k.

◆ 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

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)

Set 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 ( const decVector v)

Set components to the given vector.

◆ Set() [2/2]

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

Set components to the given values.

◆ 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.

◆ y

float decVector::y

Y Component of vector.

◆ z

float decVector::z

Z Component of vector.


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