Annchienta::Vector Class Reference
List of all members.
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:
-
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:
-
- 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.