Kaim::Vec2f Class Reference

Kaim::Vec2f Class Reference

#include <vec2f.h>

Class Description

This class defines a two-dimensional vector whose coordinates are stored using floating-point numbers.

+ Examples:

Creation & Initialization

 Vec2f ()
 
 Vec2f (KyFloat32 _x, KyFloat32 _y)
 
 Vec2f (KyFloat32 *coords)
 
void Set (KyFloat32 _x, KyFloat32 _y)
 
void Set (KyFloat32 *coords)
 

Operators

KyFloat32operator[] (KyInt32 i)
 
KyFloat32 operator[] (KyInt32 i) const
 
bool operator== (const Vec2f &v) const
 
bool operator!= (const Vec2f &v) const
 
bool operator< (const Vec2f &v) const
 
bool operator> (const Vec2f &v) const
 
bool operator<= (const Vec2f &v) const
 
bool operator>= (const Vec2f &v) const
 
Vec2foperator*= (KyFloat32 s)
 
Vec2foperator/= (KyFloat32 d)
 
Vec2foperator+= (const Vec2f &v)
 
Vec2foperator-= (const Vec2f &v)
 
Vec2f operator* (KyFloat32 s) const
 
Vec2f operator/ (KyFloat32 d) const
 
Vec2f operator+ (const Vec2f &v) const
 
Vec2f operator- (const Vec2f &v) const
 
Vec2f operator- () const
 
KyFloat32 operator* (const Vec2f &v) const
 
KyFloat32 operator^ (const Vec2f &v) const
 

Main interface

KyFloat32 GetSquareLength () const
 
KyFloat32 GetLength () const
 
KyFloat32 Normalize ()
 
KyFloat32 GetNormalized (Vec2f &normalized) const
 
Vec2f PerpCW () const
 
Vec2f PerpCCW () const
 

Static methods

static Vec2f Zero ()
 
static Vec2f UnitX ()
 
static Vec2f UnitY ()
 

Public Data Members

KyFloat32 x
 
KyFloat32 y
 

Constructor & Destructor Documentation

Kaim::Vec2f::Vec2f ( )
inline

Creates a vector with coordinates (0,0)

Kaim::Vec2f::Vec2f ( KyFloat32  _x,
KyFloat32  _y 
)
inline

Creates a vector with the specified coordinates.

Kaim::Vec2f::Vec2f ( KyFloat32 coords)
inlineexplicit

Creates a vector with the specified coordinates.

Parameters
coordsarray of coordinates {x, y}

Member Function Documentation

KyFloat32 Kaim::Vec2f::GetLength ( ) const
inline

Returns the magnitude of the vector.

KyFloat32 Kaim::Vec2f::GetNormalized ( Vec2f normalized) const
inline

Normalizes the vector, making it one unit in length without changing its orientation.

This method does not change this object. Instead, it stores the computed normal in the normalized parameter.

Parameters
[out]normalizedStores the normalized vector computed from this vector.
Returns
The magnitude of this vector before normalization.
KyFloat32 Kaim::Vec2f::GetSquareLength ( ) const
inline

Returns the square of the magnitude of the vector.

+ Examples:
KyFloat32 Kaim::Vec2f::Normalize ( )
inline

Normalizes the vector, making it one unit in length without changing its orientation.

Returns
The previous magnitude of this vector before normalization.
+ Examples:
bool Kaim::Vec2f::operator!= ( const Vec2f v) const
inline

Returns true if this object contains at least one different coordinate from v.

Vec2f Kaim::Vec2f::operator* ( KyFloat32  s) const
inline

Multiplies both the X and Y coordinates of the vector by the specified value.

KyFloat32 Kaim::Vec2f::operator* ( const Vec2f v) const
inline

Returns the dot product of this vector and v.

Vec2f& Kaim::Vec2f::operator*= ( KyFloat32  s)
inline

Multiplies both the X and Y coordinates by s.

Vec2f Kaim::Vec2f::operator+ ( const Vec2f v) const
inline

Adds the X coordinate of v to the X coordinate of this vector, and adds the Y coordinate of v to the Y coordinate of this vector.

Vec2f& Kaim::Vec2f::operator+= ( const Vec2f v)
inline

Adds the X coordinate of v to the X coordinate of this vector, and adds the Y coordinate of v to the Y coordinate of this vector.

Vec2f Kaim::Vec2f::operator- ( const Vec2f v) const
inline

Subtracts the X coordinate of v from the X coordinate of this vector, and subtracts the Y coordinate of v from the Y coordinate of this vector.

Vec2f Kaim::Vec2f::operator- ( ) const
inline

Negates the X and Y coordinates of this vector, effectively flipping it around the origin.

Vec2f& Kaim::Vec2f::operator-= ( const Vec2f v)
inline

Subtracts the X coordinate of v from the X coordinate of this vector, and subtracts the Y coordinate of v from the Y coordinate of this vector.

Vec2f Kaim::Vec2f::operator/ ( KyFloat32  d) const
inline

Divides both the X and Y coordinates of the vector by the specified value.

Vec2f& Kaim::Vec2f::operator/= ( KyFloat32  d)
inline

Divides both the X and Y coordinates ny d .

bool Kaim::Vec2f::operator< ( const Vec2f v) const
inline

x is compared first. ex: (1,5) < (2,0).

bool Kaim::Vec2f::operator== ( const Vec2f v) const
inline

Returns true if this object contains the same coordinates as v.

KyFloat32& Kaim::Vec2f::operator[] ( KyInt32  i)
inline

Retrieves the coordinates of the vector. Use [0] for the X axis, or [1] for the Y axis.

KyFloat32 Kaim::Vec2f::operator[] ( KyInt32  i) const
inline

Retrieves the coordinates of the vector. Use [0] for the X axis, or [1] for the Y axis. const version.

KyFloat32 Kaim::Vec2f::operator^ ( const Vec2f v) const
inline

Returns the magnitude on the Z axis of the cross product between this vector and v.

Vec2f Kaim::Vec2f::PerpCCW ( ) const
inline

Rotates this vector 90 degrees counter-clockwise (negating the Y coordinate).

Vec2f Kaim::Vec2f::PerpCW ( ) const
inline

Rotates this vector 90 degrees clockwise (negating the X coordinate).

void Kaim::Vec2f::Set ( KyFloat32  _x,
KyFloat32  _y 
)
inline

Sets the coordinates of the vector.

+ Examples:
void Kaim::Vec2f::Set ( KyFloat32 coords)
inline

Sets the coordinates of the vector.

Parameters
coordsarray of coordinates {x, y}
static Vec2f Kaim::Vec2f::UnitX ( )
inlinestatic

Returns the normalized orientation of the X axis.

+ Examples:
static Vec2f Kaim::Vec2f::UnitY ( )
inlinestatic

Returns the normalized orientation of the Y axis.

+ Examples:
static Vec2f Kaim::Vec2f::Zero ( )
inlinestatic

Returns a vector of zero size: (0,0).

Member Data Documentation

KyFloat32 Kaim::Vec2f::x

The size of the vector along the X axis.

KyFloat32 Kaim::Vec2f::y

The size of the vector along the Y axis.


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