The BPoint class defines a point in the plane using integer precision. More...
#include <BPoint.h>
Public Member Functions | |
BPoint () | |
Constructs a BPoint with an X and Y of 0. More... | |
BPoint (int xpos, int ypos) | |
Constructs a BPoint with a given X and Y. More... | |
bool | IsNull () const |
Determines whether both X and Y are 0. More... | |
int | X () const |
Retrieves the X value. More... | |
int | Y () const |
Retrieves the Y value. More... | |
void | SetX (int x) |
Sets the X value. More... | |
void | SetY (int y) |
Sets the Y value. More... | |
BPoint & | operator+= (const BPoint &p) |
Operator overload for += (add and assign). More... | |
BPoint & | operator-= (const BPoint &p) |
Operator overload for -= (subtract and assign). More... | |
BPoint & | operator*= (double c) |
Operator overload for *= (multiply and assign). More... | |
BPoint & | operator/= (double c) |
Operator overload for /= (divide and assign). More... | |
Friends | |
bool | operator== (const BPoint &, const BPoint &) |
Operator overload for == (equality test). More... | |
bool | operator!= (const BPoint &, const BPoint &) |
Operator overload for != (not equal test). More... | |
const BPoint | operator+ (const BPoint &, const BPoint &) |
Operator overload for + (add). More... | |
const BPoint | operator- (const BPoint &, const BPoint &) |
Operator overload for - (subtract). More... | |
const BPoint | operator* (const BPoint &, double) |
Operator overload for * (multiply with a double). More... | |
const BPoint | operator* (double, const BPoint &) |
Operator overload for * (multiply with a double). More... | |
const BPoint | operator- (const BPoint &) |
Operator overload for - (subtract). More... | |
const BPoint | operator/ (const BPoint &, double) |
Operator overload for / (divide). More... | |
The BPoint class defines a point in the plane using integer precision.
A point is specified by an X coordinate and a Y coordinate which can be accessed using the X() and Y() functions. The IsNull() function returns true if both x and y are set to 0. The coordinates can be set (or altered) using the SetX() and SetY() functions.
A BPoint object can also be used as a vector: Addition and subtraction are defined as for vectors (each component is added separately). A BPoint object can also be divided or multiplied by an int or a double.
bool IsNull | ( | ) | const |
Determines whether both X and Y are 0.
BPoint& operator*= | ( | double | c | ) |
Operator overload for *= (multiply and assign).
BPoint& operator/= | ( | double | c | ) |
Operator overload for /= (divide and assign).
void SetX | ( | int | x | ) |
Sets the X value.
void SetY | ( | int | y | ) |
Sets the Y value.
int X | ( | ) | const |
Retrieves the X value.
Referenced by operator!=(), operator*(), operator+(), operator-(), operator/(), and operator==().
int Y | ( | ) | const |
Retrieves the Y value.
Referenced by operator!=(), operator*(), operator+(), operator-(), operator/(), and operator==().
Operator overload for != (not equal test).
Operator overload for * (multiply with a double).
Operator overload for * (multiply with a double).
Operator overload for + (add).
Operator overload for - (subtract).
Operator overload for == (equality test).