Annchienta::Vector Class Reference

List of all members.

Public Member Functions

void cap (const float &minimum, const float &maximum)
float distance (const Vector &other) const
float length () const
float lengthSquared () const
void normalize ()
float operator* (const Vector &other) const
Vector operator* (const float &scalar) const
Vectoroperator*= (const float &scalar)
Vector operator+ (const Vector &other) const
Vectoroperator+= (const Vector &other)
Vector operator- (const Vector &other) const
Vectoroperator-= (const Vector &other)
Vector operator/ (const float &scalar) const
Vectoroperator/= (const float &scalar)
Vectoroperator= (const Vector &other)
 Vector (const Vector &other)
 Vector (float x, float y)
 ~Vector ()

Public Attributes

float x
float y


Detailed Description

This is a class that can be used to perform mathematical operations with 2D vectors, and thus comes in handy in a lot of games.

Note that this class is designed to be 'independent' of the other classes in the engine, meaning no functions in the engine will require or return Vectors (altough some classes use this class internally).

If you want to represent a point on the map, it would be better to use the Point class, designed for this.


Constructor & Destructor Documentation

Annchienta::Vector::Vector ( float  x,
float  y 
)

Creates a new Vector with given coordinates.

Parameters:
x X coordinate for the Vector.
y Y coordinate for the Vector.

Annchienta::Vector::Vector ( const Vector other  ) 

Creates a new Vector based on another Vector, copy constructor.

Parameters:
other Vector to copy.

Annchienta::Vector::~Vector (  ) 


Member Function Documentation

void Annchienta::Vector::cap ( const float &  minimum,
const float &  maximum 
)

Cap the vector coordinates. For example, a vector with coordinates (-5,2) would become (-3,2) after capping with -3 as mimimum and 3 as maximum.

Parameters:
minimum The mimum value of a coordinate.
maximum The maximum value of a coordinate.

float Annchienta::Vector::distance ( const Vector other  )  const

Calculates the distance between the representation of this Vector as a cartesian coordinate and an the representation of another Vector.

Parameters:
other The other Vector.
Returns:
The distance between this and the other Vector.

float Annchienta::Vector::length (  )  const

Gets the length of this Vector.

Returns:
This Vector's length.

float Annchienta::Vector::lengthSquared (  )  const

Returns the squared length of this Vector. this method is a lot faster than the length() method.

Returns:
The length of this Vector, squared.

void Annchienta::Vector::normalize (  ) 

Normalizes the Vector: this will change the Vector so it has length 1, while maintaining the ratio between the X and Y values.

float Annchienta::Vector::operator* ( const Vector other  )  const

Note: this calculates the Dot product.

Vector Annchienta::Vector::operator* ( const float &  scalar  )  const

Vector& Annchienta::Vector::operator*= ( const float &  scalar  ) 

Vector Annchienta::Vector::operator+ ( const Vector other  )  const

Vector& Annchienta::Vector::operator+= ( const Vector other  ) 

Vector Annchienta::Vector::operator- ( const Vector other  )  const

Vector& Annchienta::Vector::operator-= ( const Vector other  ) 

Vector Annchienta::Vector::operator/ ( const float &  scalar  )  const

Vector& Annchienta::Vector::operator/= ( const float &  scalar  ) 

Vector& Annchienta::Vector::operator= ( const Vector other  ) 


Member Data Documentation

The X coordinate of the Vector.

The Y coordinate of the Vector.


Generated on Wed Feb 4 16:31:47 2009 for Annchienta by  doxygen 1.5.7.1