|
VR-Engage
2.2
|
This class provides functionality for working with 2D vectors including basic vector operations such as length calculation, normalization, and rotation.
#include <vector2DD.h>
Public Member Functions | |
| DtVector2DD () | |
| DtVector2DD (double x, double y) | |
| DtVector2DD (const DtVector2DD &orig) | |
| const DtVector2DD & | operator= (const DtVector2DD &orig) |
| DtVector2DD & | operator/= (double scalar) |
| void | setX (double x) |
| double | x () const |
| void | setY (double y) |
| double | y () const |
| void | rotate (double rotationAngle) |
| double | length () const |
| double | lengthSquared () const |
| void | normalize () |
Protected Attributes | |
| double | myX |
| double | myY |
| makVre::DtVector2DD::DtVector2DD | ( | ) |
Default constructor.
Creates a vector with coordinates (0,0)
Referenced by DtVector2DD(), operator/=(), and operator=().
| makVre::DtVector2DD::DtVector2DD | ( | double | x, |
| double | y ) |
| makVre::DtVector2DD::DtVector2DD | ( | const DtVector2DD & | orig | ) |
| const DtVector2DD & makVre::DtVector2DD::operator= | ( | const DtVector2DD & | orig | ) |
Assignment operator.
| orig | The vector to copy |
References DtVector2DD().
|
inline |
Division assignment operator.
Divides both x and y components by a scalar value
| scalar | The scalar to divide by |
References DtVector2DD().
| void makVre::DtVector2DD::setX | ( | double | x | ) |
| double makVre::DtVector2DD::x | ( | ) | const |
Gets the x coordinate.
Referenced by DtVector2DD(), makVre::operator<<(), and setX().
| void makVre::DtVector2DD::setY | ( | double | y | ) |
| double makVre::DtVector2DD::y | ( | ) | const |
Gets the y coordinate.
Referenced by DtVector2DD(), makVre::operator<<(), and setY().
|
inline |
Rotates the vector counter-clockwise.
| rotationAngle | The angle to rotate in radians |
|
inline |
Calculates the length/magnitude of the vector.
|
inline |
Calculates the squared length/magnitude of the vector.
This is more efficient than length() when comparing distances, as it avoids the square root calculation
| void makVre::DtVector2DD::normalize | ( | ) |
Normalizes the vector.
Adjusts the vector to have a length of 1 while preserving its direction
|
protected |
The x coordinate.
|
protected |
The y coordinate.