lab_inheritance
Insidious Inheritance
|
Represents a 2 dimensional vector. More...
#include <vector2.h>
Public Member Functions | |
Vector2 () | |
Constructs a new Vector2 at (0, 0) More... | |
Vector2 (double x, double y) | |
Constructs a new Vector2 at (x, y) More... | |
Vector2 | operator- (const Vector2 &other) const |
Subtracts two Vector2s and returns the value. More... | |
Vector2 | operator+ (const Vector2 &other) const |
Adds two Vector2s together and returns the value. More... | |
Vector2 | operator* (int constant) |
Multiples the current Vector2 by a scalar and returns a new Vector2 with its value. More... | |
Vector2 | operator/ (int constant) |
Divides the current Vector2 by a scalar and returns a new Vector2 with its value. More... | |
bool | operator== (const Vector2 &other) const |
Checks to see if the current Vector2 equals the other Vector2. More... | |
double | x () const |
Gets the x coordinate of the Vector2. More... | |
void | setX (double x) |
Sets the x coordinate of the Vector2. More... | |
double | y () const |
Gets the y coordinate of the Vector2. More... | |
void | setY (double y) |
Sets the y coordinate of the Vector2. More... | |
double | distanceTo (const Vector2 &other) const |
Computes and returns the distance from the current Vector2 to the other Vector2. More... | |
bool | isNorthOf (const Vector2 &other) const |
Checks if the current Vector2 is north of the other Vector2. More... | |
bool | isNorthWestOf (const Vector2 &other) const |
Checks if the current Vector2 is north west of the other Vector2. More... | |
bool | isNorthEastOf (const Vector2 &other) const |
Checks if the current Vector2 is north east of the other Vector2. More... | |
bool | isSouthOf (const Vector2 &other) const |
Checks if the current Vector2 is south of the other Vector2. More... | |
bool | isSouthWestOf (const Vector2 &other) const |
Checks if the current Vector2 is south west of the other Vector2. More... | |
bool | isSouthEastOf (const Vector2 &other) const |
Checks if the current Vector2 is south east of the other Vector2. More... | |
bool | isWestOf (const Vector2 &other) const |
Checks if the current Vector2 is west of the other Vector2. More... | |
bool | isEastOf (const Vector2 &other) const |
Checks if the current Vector2 is east of the other Vector2. More... | |
double | dotProduct (const Vector2 &other) const |
Computes and returns the dot product of the current Vector2 and other Vector2. More... | |
double | crossProduct (const Vector2 &other) const |
Computes and returns the cross product of the current Vector2 and the other Vector2. More... | |
Vector2 | projectionOn (const Vector2 &b) const |
Computes and returns the projection of the current Vector2 onto b. More... | |
double | length () const |
Computes and returns the length of the Vector2 from the origin. More... | |
double | length2 () const |
Computes and returns the length^2 of the Vector2 from the origin. More... | |
double | magnitude () const |
Computes and returns the magnitude of the Vector2. More... | |
Vector2 | normalize () const |
Computes and returns the normalized form of the current Vector2. More... | |
Vector2 | leftHandNormal () const |
Computes and returns the left hand normal of the current Vector2. More... | |
Vector2 | rightHandNormal () const |
Computes and returns the right hand normal of the current Vector2. More... | |
Private Attributes | |
double | x_ |
The X coordinate of this vector. More... | |
double | y_ |
The Y coordinate of this vector. More... | |
Represents a 2 dimensional vector.
Vector2::Vector2 | ( | ) |
Constructs a new Vector2 at (0, 0)
Vector2::Vector2 | ( | double | x, |
double | y | ||
) |
Constructs a new Vector2 at (x, y)
x | |
y |
double Vector2::crossProduct | ( | const Vector2 & | other | ) | const |
double Vector2::distanceTo | ( | const Vector2 & | other | ) | const |
double Vector2::dotProduct | ( | const Vector2 & | other | ) | const |
bool Vector2::isEastOf | ( | const Vector2 & | other | ) | const |
bool Vector2::isNorthEastOf | ( | const Vector2 & | other | ) | const |
bool Vector2::isNorthOf | ( | const Vector2 & | other | ) | const |
bool Vector2::isNorthWestOf | ( | const Vector2 & | other | ) | const |
bool Vector2::isSouthEastOf | ( | const Vector2 & | other | ) | const |
bool Vector2::isSouthOf | ( | const Vector2 & | other | ) | const |
bool Vector2::isSouthWestOf | ( | const Vector2 & | other | ) | const |
bool Vector2::isWestOf | ( | const Vector2 & | other | ) | const |
Vector2 Vector2::leftHandNormal | ( | ) | const |
double Vector2::length | ( | ) | const |
double Vector2::length2 | ( | ) | const |
double Vector2::magnitude | ( | ) | const |
Vector2 Vector2::normalize | ( | ) | const |
Vector2 Vector2::operator* | ( | int | constant | ) |
Vector2 Vector2::operator/ | ( | int | constant | ) |
bool Vector2::operator== | ( | const Vector2 & | other | ) | const |
Vector2 Vector2::rightHandNormal | ( | ) | const |
void Vector2::setX | ( | double | x | ) |
void Vector2::setY | ( | double | y | ) |
double Vector2::x | ( | ) | const |
double Vector2::y | ( | ) | const |
|
private |
The X coordinate of this vector.
|
private |
The Y coordinate of this vector.