#include <point.h>
Public Member Functions | |
| Point () | |
| The point (0, 0). | |
| Point (int a, int b) | |
| The point (a, b). | |
| Point (const Point &p) | |
| double | length () |
| int | taxiLength () |
| Point | operator+ (const Point &a) const |
| Point | operator- (const Point &a) const |
| void | operator+= (const Point &a) |
| void | operator-= (const Point &a) |
| void | operator*= (const double a) |
| void | operator/= (const double a) |
| bool | operator== (const Point &a) const |
| bool | operator!= (const Point &a) const |
| bool | operator< (const Point &a) const |
| bool | operator> (const Point &a) const |
| bool | in (Point topLeft, Point bottomRight) |
| Is this point in the box defined by these other two points? | |
Public Attributes | |
| int | x |
| int | y |
This is a simple struct that that does nothing more than hold an (x, y) pair. Note that this can be used for a location or it can be used as a vector.
The x and y coordinates are public, so they can be accessed as p.x and p.y. The following operators are overloaded, and act as you would expect:
==
!=
+/-
+=
-=
*=
/=
Note that *= and /= take a double as the right side, and coordinates are rounded as normal for integers. The operators > and < are also overloaded, but only for easy compatibility with the standard template library. Don't use them.
The following two points are specified:
ORIGIN (0,0)
OFFSCREEN (-9999,-9999)
| Point::Point | ( | ) | [inline] |
The point (0, 0).
| Point::Point | ( | int | a, | |
| int | b | |||
| ) | [inline] |
The point (a, b).
| Point::Point | ( | const Point & | p | ) | [inline] |
Is this point in the box defined by these other two points?
| double Point::length | ( | ) | [inline] |
The length of the vector represented by this point. Alternatively, the distance from here to (0,0).
| bool Point::operator!= | ( | const Point & | a | ) | const [inline] |
| void Point::operator*= | ( | const double | a | ) | [inline] |
| void Point::operator+= | ( | const Point & | a | ) | [inline] |
| void Point::operator-= | ( | const Point & | a | ) | [inline] |
| void Point::operator/= | ( | const double | a | ) | [inline] |
| bool Point::operator< | ( | const Point & | a | ) | const [inline] |
| bool Point::operator== | ( | const Point & | a | ) | const [inline] |
| bool Point::operator> | ( | const Point & | a | ) | const [inline] |
| int Point::taxiLength | ( | ) | [inline] |
The taxicab distance from here to (0,0).
| int Point::x |
| int Point::y |
1.5.7.1