Public Methods | |
Coord2D () | |
Coord2D (double x, double y=0.0) | |
void | setCoords (double x=0.0, double y=0.0) |
Coord2D & | operator+= (const Coord2D &coord) |
Coord2D & | operator-= (const Coord2D &coord) |
Coord2D | operator+ (const Coord2D &coord) const |
Coord2D | operator- (const Coord2D &coord) const |
Coord2D | operator- () const |
bool | operator== (const Coord2D &coord) const |
Coord2D & | operator= (const Coord2D &coord) |
Coord2D & | operator *= (double d) |
Coord2D & | operator/= (double d) |
Coord2D | operator * (double d) const |
Coord2D | operator/ (double d) const |
double & | operator[] (int i) |
double | operator[] (int i) const |
double | sqrabs () const |
double | abs () const |
Coord2D | unit () const |
void | normalize () |
Public Attributes | |
double | x |
double | y |
Friends | |
double | dot (const Coord2D &c1, const Coord2D &c2) |
Every component (x and y) is a double. The coordinate can also be used as a vector, starting at (0,0) and ending at (x,y).
|
Default constructor. Initializes the coordinate to (0, 0). |
|
Constructor. Initializes the coordinate to (x, y).
|
|
Returns the length of the vector. It is also the square root of the dot product between the vector and itself
|
|
Normalizes the vector to be of length=1.
|
|
Multiplies coordinate by d, returns a new Coord2D object.
|
|
Multiplies coordinate by d.
|
|
Adds coord to current coordinate.
|
|
Adds coord to current coordinate.
|
|
Returns the current coordinate multiplied by -1.
|
|
Subtract coord from current coordinate.
|
|
Subtract coord from current coordinate.
|
|
Divides coordinate by d, returns a new Coord2D object.
|
|
Divides coordinate by d.
|
|
Compares 2 coordinates and returns true if they are the same.
|
|
Compares 2 coordinates and returns true if they are the same.
|
|
Returns the x/y/z coordinate (depends on i).
|
|
Returns the x/y coordinate (depends on i).
|
|
Set the coordinate.
|
|
Returns the norm of the vector. It is also the dot product between the vector and itself
|
|
Returns a normalized vector (same direction as original vector, but with length=1).
|
|
Returns the dot product between the 2 coordinates.
|
|
The x coordinate.
|
|
The y coordinate.
|