Pyrogenesis trunk
Public Member Functions | Public Attributes | List of all members
CFixedVector2D Class Reference

#include <FixedVector2D.h>

Collaboration diagram for CFixedVector2D:
Collaboration graph
[legend]

Public Member Functions

 CFixedVector2D ()
 
 CFixedVector2D (fixed X, fixed Y)
 
bool operator== (const CFixedVector2D &v) const
 Vector equality. More...
 
bool operator!= (const CFixedVector2D &v) const
 Vector inequality. More...
 
CFixedVector2D operator+ (const CFixedVector2D &v) const
 Vector addition. More...
 
CFixedVector2D operator- (const CFixedVector2D &v) const
 Vector subtraction. More...
 
CFixedVector2D operator- () const
 Negation. More...
 
CFixedVector2Doperator+= (const CFixedVector2D &v)
 Vector addition. More...
 
CFixedVector2Doperator-= (const CFixedVector2D &v)
 Vector subtraction. More...
 
CFixedVector2D operator* (int n) const
 Scalar multiplication by an integer. More...
 
CFixedVector2D operator/ (int n) const
 Scalar division by an integer. Must not have n == 0. More...
 
CFixedVector2D Multiply (fixed n) const
 Multiply by a CFixed. More...
 
fixed Length () const
 Returns the length of the vector. More...
 
int CompareLength (fixed cmp) const
 Returns -1, 0, +1 depending on whether length is less/equal/greater than the argument. More...
 
int CompareLengthSquared (u64 cmpSquared) const
 Same as above, but avoids squaring the compared value. More...
 
int CompareLength (const CFixedVector2D &other) const
 Returns -1, 0, +1 depending on whether length is less/equal/greater than the argument's length. More...
 
bool IsZero () const
 
void Normalize ()
 Normalize the vector so that length is close to 1. More...
 
void Normalize (fixed n)
 Normalize the vector so that length is close to n. More...
 
fixed Dot (const CFixedVector2D &v) const
 Compute the dot product of this vector with another. More...
 
int RelativeOrientation (const CFixedVector2D &v) const
 
CFixedVector2D Perpendicular () const
 
CFixedVector2D Rotate (fixed angle) const
 Rotate the vector by the given angle (anticlockwise). More...
 

Public Attributes

fixed X
 
fixed Y
 

Constructor & Destructor Documentation

◆ CFixedVector2D() [1/2]

CFixedVector2D::CFixedVector2D ( )
inline

◆ CFixedVector2D() [2/2]

CFixedVector2D::CFixedVector2D ( fixed  X,
fixed  Y 
)
inline

Member Function Documentation

◆ CompareLength() [1/2]

int CFixedVector2D::CompareLength ( const CFixedVector2D other) const
inline

Returns -1, 0, +1 depending on whether length is less/equal/greater than the argument's length.

Avoids sqrting and overflowing.

◆ CompareLength() [2/2]

int CFixedVector2D::CompareLength ( fixed  cmp) const
inline

Returns -1, 0, +1 depending on whether length is less/equal/greater than the argument.

Avoids sqrting and overflowing.

◆ CompareLengthSquared()

int CFixedVector2D::CompareLengthSquared ( u64  cmpSquared) const
inline

Same as above, but avoids squaring the compared value.

The argument must be the result of an SQUARE_U64_FIXED operation.

◆ Dot()

fixed CFixedVector2D::Dot ( const CFixedVector2D v) const
inline

Compute the dot product of this vector with another.

Likely to overflow if both vectors are large-ish (around the 200 range).

◆ IsZero()

bool CFixedVector2D::IsZero ( ) const
inline

◆ Length()

fixed CFixedVector2D::Length ( ) const
inline

Returns the length of the vector.

Will not overflow if the result can be represented as type 'fixed'.

◆ Multiply()

CFixedVector2D CFixedVector2D::Multiply ( fixed  n) const
inline

Multiply by a CFixed.

Likely to overflow if both numbers are large, so we use an ugly name instead of operator* to make it obvious.

◆ Normalize() [1/2]

void CFixedVector2D::Normalize ( )
inline

Normalize the vector so that length is close to 1.

If length is 0, does nothing.

◆ Normalize() [2/2]

void CFixedVector2D::Normalize ( fixed  n)
inline

Normalize the vector so that length is close to n.

If length is 0, does nothing.

◆ operator!=()

bool CFixedVector2D::operator!= ( const CFixedVector2D v) const
inline

Vector inequality.

◆ operator*()

CFixedVector2D CFixedVector2D::operator* ( int  n) const
inline

Scalar multiplication by an integer.

◆ operator+()

CFixedVector2D CFixedVector2D::operator+ ( const CFixedVector2D v) const
inline

Vector addition.

◆ operator+=()

CFixedVector2D & CFixedVector2D::operator+= ( const CFixedVector2D v)
inline

Vector addition.

◆ operator-() [1/2]

CFixedVector2D CFixedVector2D::operator- ( ) const
inline

Negation.

◆ operator-() [2/2]

CFixedVector2D CFixedVector2D::operator- ( const CFixedVector2D v) const
inline

Vector subtraction.

◆ operator-=()

CFixedVector2D & CFixedVector2D::operator-= ( const CFixedVector2D v)
inline

Vector subtraction.

◆ operator/()

CFixedVector2D CFixedVector2D::operator/ ( int  n) const
inline

Scalar division by an integer. Must not have n == 0.

◆ operator==()

bool CFixedVector2D::operator== ( const CFixedVector2D v) const
inline

Vector equality.

◆ Perpendicular()

CFixedVector2D CFixedVector2D::Perpendicular ( ) const
inline

◆ RelativeOrientation()

int CFixedVector2D::RelativeOrientation ( const CFixedVector2D v) const
inline
Returns
-1, 0 or 1 if this and @v face respectively opposite directions, perpendicular, or same directions.

◆ Rotate()

CFixedVector2D CFixedVector2D::Rotate ( fixed  angle) const
inline

Rotate the vector by the given angle (anticlockwise).

Member Data Documentation

◆ X

fixed CFixedVector2D::X

◆ Y

fixed CFixedVector2D::Y

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