All Classes Namespaces Files Functions Variables Typedefs Pages
Public Member Functions | Public Attributes | List of all members
TTC::Vector2D Class Reference

A two-dimensional vector class. More...

#include <Vector2D.h>

Public Member Functions

 Vector2D ()
 
 Vector2D (const Vector2D &v)
 Copy constructor. More...
 
 Vector2D (float _x, float _y)
 Constructor. More...
 
Vector2D operator+ (const Vector2D &v) const
 Vector addition. More...
 
Vector2D operator- (const Vector2D &v) const
 Vector subtraction. More...
 
float operator* (const Vector2D &v) const
 Dot product. More...
 
Vector2D operator* (const float a) const
 Scalar multiplication. More...
 
Vector2D operator/ (const float a) const
 Scalar division. More...
 
float operator^ (const Vector2D &v) const
 Cross product. More...
 
void operator+= (const Vector2D &v)
 Adds a 2d vector to the current vector. More...
 
void operator-= (const Vector2D &v)
 Subtracts a 2d vector from the current vector. More...
 
void operator*= (const float &a)
 Multiplies the vector by a scalar. More...
 
void operator/= (const float &a)
 Divides the vector by a scalar. More...
 
bool operator== (const Vector2D &v) const
 Vector equality. More...
 
bool operator!= (const Vector2D &v) const
 Vector inequality. More...
 
void normalize ()
 
float length () const
 
float lengthSqr () const
 
Vector2D perpendicular () const
 

Public Attributes

float x
 
float y
 

Detailed Description

A two-dimensional vector class.

Constructor & Destructor Documentation

TTC::Vector2D::Vector2D ( )
inline

Constructs a null vector.

TTC::Vector2D::Vector2D ( const Vector2D v)
inline

Copy constructor.

Parameters
vThe vector to be copied.
TTC::Vector2D::Vector2D ( float  _x,
float  _y 
)
inline

Constructor.

Parameters
_xThe x-component of the new vector.
_yThe y-component of the new vector.

Member Function Documentation

float TTC::Vector2D::length ( ) const
inline
Returns
The magnitude of the vector.
float TTC::Vector2D::lengthSqr ( ) const
inline
Returns
The squared magnitude of the vector.
void TTC::Vector2D::normalize ( )
inline
Returns
This function normalizes the x and y coordinate.
bool TTC::Vector2D::operator!= ( const Vector2D v) const
inline

Vector inequality.

Parameters
vThe right hand side vector
Returns
True if the two vector are not equal. False otherwise.
float TTC::Vector2D::operator* ( const Vector2D v) const
inline

Dot product.

Parameters
vThe right hand side vector
Returns
The dot product of the two vectors.
Vector2D TTC::Vector2D::operator* ( const float  a) const
inline

Scalar multiplication.

Parameters
aThe scalar.
void TTC::Vector2D::operator*= ( const float &  a)
inline

Multiplies the vector by a scalar.

Parameters
aThe scalar.
Vector2D TTC::Vector2D::operator+ ( const Vector2D v) const
inline

Vector addition.

Parameters
vThe vector to be added.
Returns
The sum of the two vectors.
void TTC::Vector2D::operator+= ( const Vector2D v)
inline

Adds a 2d vector to the current vector.

Parameters
vThe vector to be added.
Vector2D TTC::Vector2D::operator- ( const Vector2D v) const
inline

Vector subtraction.

Parameters
vThe vector to be added.
Returns
The vector difference.
void TTC::Vector2D::operator-= ( const Vector2D v)
inline

Subtracts a 2d vector from the current vector.

Parameters
vThe vector to be substracted.
Vector2D TTC::Vector2D::operator/ ( const float  a) const
inline

Scalar division.

Parameters
aThe scalar.
void TTC::Vector2D::operator/= ( const float &  a)
inline

Divides the vector by a scalar.

Parameters
aThe scalar.
bool TTC::Vector2D::operator== ( const Vector2D v) const
inline

Vector equality.

Parameters
vThe right hand side vector
Returns
True if the vectors are equal. False otherwise.
float TTC::Vector2D::operator^ ( const Vector2D v) const
inline

Cross product.

Parameters
vThe right hand side vector
Returns
The cross product of the two vectors.
Vector2D TTC::Vector2D::perpendicular ( ) const
inline
Returns
A vector perpendicular to the current vector.

Member Data Documentation

float TTC::Vector2D::x

The x-component of the vector.

float TTC::Vector2D::y

The y-component of the vector.


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