Drag[en]gine Game Engine  1.0
decVector2 Class Reference

2 component vector. More...

#include <decVector2.h>

Public Member Functions

Constructors and Destructors
 decVector2 ()
 Create zero vector. More...
 
 decVector2 (float nx, float ny)
 Create vector with initial values. More...
 
 decVector2 (const decVector2 &v)
 Create copy of vector. More...
 
 decVector2 (const decPoint &p)
 Create vector from point. More...
 
Management
float Length () const
 Length. More...
 
void Normalize ()
 Normalize vector. More...
 
decVector2 Normalized () const
 Normalized vector. More...
 
const decVector2 Absolute () const
 Absolute vector. More...
 
void Snap (float grid)
 Snaps the components of the vector to a grid with the given size. More...
 
bool IsEqualTo (const decVector2 &v, float threshold=VECTOR_THRESHOLD) const
 Component of vector are equal to another one with respect to a threshold. More...
 
void SetZero ()
 Set all components to 0. More...
 
void Set (float nx, float ny)
 Set components to the given values. More...
 
void Set (const decVector2 &v)
 Set components to the given vector. More...
 
void Negate ()
 Negate vector. More...
 
void SetSmallest (const decVector2 &v)
 Set each component to the smallest value of this vector and another vector. More...
 
decVector2 Smallest (const decVector2 &v) const
 Vector with each component set to the smallest value of this vector and another vector. More...
 
void SetLargest (const decVector2 &v)
 Set each component to the largest value of this vector and another vector. More...
 
decVector2 Largest (const decVector2 &v) const
 Vector with each component set to the largest value of this vector and another vector. More...
 
void SetClamped (const decVector2 &minValue, const decVector2 &maxValue)
 Clamp each component to the provided range. More...
 
decVector2 Clamped (const decVector2 &minValue, const decVector2 &maxValue) const
 Vector with each component clamped to the provided range. More...
 
decVector2 RotateLeft () const
 Rotate vector counter-clock-wise by 90 degrees. More...
 
decVector2 RotateRight () const
 Rotate vector clock-wise by 90 degrees. More...
 
decPoint Round () const
 Convert to point rounding to the nearest integer value. More...
 
Operators
decVector2 operator- () const
 Negation of this vector. More...
 
decVector2operator= (const decVector2 &v)
 Set components of this vector to the values of another one. More...
 
decVector2operator+= (const decVector2 &v)
 Add components of another vector to this one. More...
 
decVector2operator-= (const decVector2 &v)
 Subtract components of another vector from this vector. More...
 
decVector2operator*= (float k)
 Multiply components of this vector with a value k. More...
 
decVector2operator/= (float k)
 Divide components of this vector by a value k. More...
 
decVector2 operator+ (const decVector2 &v) const
 Vector with the sum of this vector with another one. More...
 
decVector2 operator- (const decVector2 &v) const
 Vector with the difference of this vector to another one. More...
 
decVector2 operator* (float k) const
 Vector with this vector scaled by k. More...
 
float operator* (const decVector2 &v) const
 Calculate dot product of this vector with another one. More...
 
decVector2 operator/ (float k) const
 Vector with this vector divided by k. More...
 
bool operator< (const decVector2 &v) const
 All the components of this vector are less then the components of another one. More...
 
bool operator> (const decVector2 &v) const
 All the components of this vector are greater then the components of another one. More...
 
bool operator<= (const decVector2 &v) const
 All the components of this vector are less then or equal to the components of another one. More...
 
bool operator>= (const decVector2 &v) const
 All the components of this vector are greater then or equal to the components of another one. More...
 

Public Attributes

float x
 
float y
 

Detailed Description

2 component vector.

Constructor & Destructor Documentation

◆ decVector2() [1/4]

decVector2::decVector2 ( )

Create zero vector.

◆ decVector2() [2/4]

decVector2::decVector2 ( float  nx,
float  ny 
)

Create vector with initial values.

◆ decVector2() [3/4]

decVector2::decVector2 ( const decVector2 v)

Create copy of vector.

◆ decVector2() [4/4]

decVector2::decVector2 ( const decPoint p)

Create vector from point.

Member Function Documentation

◆ Absolute()

const decVector2 decVector2::Absolute ( ) const

Absolute vector.

◆ Clamped()

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

Vector with each component clamped to the provided range.

◆ IsEqualTo()

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

Component of vector are equal to another one with respect to a threshold.

◆ Largest()

decVector2 decVector2::Largest ( const decVector2 v) const

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

◆ Length()

float decVector2::Length ( ) const

Length.

◆ Negate()

void decVector2::Negate ( )

Negate vector.

◆ Normalize()

void decVector2::Normalize ( )

Normalize vector.

Exceptions
deeDivisionByZeroLength of vector is 0.

◆ Normalized()

decVector2 decVector2::Normalized ( ) const

Normalized vector.

Exceptions
deeDivisionByZeroLength of vector is 0.

◆ operator*() [1/2]

decVector2 decVector2::operator* ( float  k) const

Vector with this vector scaled by k.

◆ operator*() [2/2]

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

Calculate dot product of this vector with another one.

◆ operator*=()

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

Multiply components of this vector with a value k.

◆ operator+()

decVector2 decVector2::operator+ ( const decVector2 v) const

Vector with the sum of this vector with another one.

◆ operator+=()

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

Add components of another vector to this one.

◆ operator-() [1/2]

decVector2 decVector2::operator- ( ) const

Negation of this vector.

◆ operator-() [2/2]

decVector2 decVector2::operator- ( const decVector2 v) const

Vector with the difference of this vector to another one.

◆ operator-=()

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

Subtract components of another vector from this vector.

◆ operator/()

decVector2 decVector2::operator/ ( float  k) const

Vector with this vector divided by k.

Exceptions
deeDivisionByZeroLength of vector is 0.

◆ operator/=()

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

Divide components of this vector by a value k.

Exceptions
deeDivisionByZeroLength of vector is 0.

◆ operator<()

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

All the components of this vector are less then the components of another one.

◆ operator<=()

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

All the components of this vector are less then or equal to the components of another one.

◆ operator=()

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

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

◆ operator>()

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

All the components of this vector are greater then the components of another one.

◆ operator>=()

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

All the components of this vector are greater then or equal to the components of another one.

◆ RotateLeft()

decVector2 decVector2::RotateLeft ( ) const

Rotate vector counter-clock-wise by 90 degrees.

◆ RotateRight()

decVector2 decVector2::RotateRight ( ) const

Rotate vector clock-wise by 90 degrees.

◆ Round()

decPoint decVector2::Round ( ) const

Convert to point rounding to the nearest integer value.

◆ Set() [1/2]

void decVector2::Set ( float  nx,
float  ny 
)

Set components to the given values.

◆ Set() [2/2]

void decVector2::Set ( const decVector2 v)

Set components to the given vector.

◆ SetClamped()

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

Clamp each component to the provided range.

◆ SetLargest()

void decVector2::SetLargest ( const decVector2 v)

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

◆ SetSmallest()

void decVector2::SetSmallest ( const decVector2 v)

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

◆ SetZero()

void decVector2::SetZero ( )

Set all components to 0.

◆ Smallest()

decVector2 decVector2::Smallest ( const decVector2 v) const

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

◆ Snap()

void decVector2::Snap ( float  grid)

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

Member Data Documentation

◆ x

float decVector2::x

◆ y

float decVector2::y

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