A pair of (x, y) co-ordinates. More...
Public Member Functions | |
| Point () noexcept | |
| Creates a point with co-ordinates (0, 0). | |
| Point (const Point &other) noexcept | |
| Creates a copy of another point. | |
| Point (const ValueType initialX, const ValueType initialY) noexcept | |
| Creates a point from an (x, y) position. | |
| ~Point () noexcept | |
| Destructor. | |
| Point & | operator= (const Point &other) noexcept |
| Copies this point from another one. | |
| bool | operator== (const Point &other) const noexcept |
| bool | operator!= (const Point &other) const noexcept |
| bool | isOrigin () const noexcept |
| Returns true if the point is (0, 0). | |
| ValueType | getX () const noexcept |
| Returns the point's x co-ordinate. | |
| ValueType | getY () const noexcept |
| Returns the point's y co-ordinate. | |
| void | setX (const ValueType newX) noexcept |
| Sets the point's x co-ordinate. | |
| void | setY (const ValueType newY) noexcept |
| Sets the point's y co-ordinate. | |
| Point | withX (const ValueType newX) const noexcept |
| Returns a point which has the same Y position as this one, but a new X. | |
| Point | withY (const ValueType newY) const noexcept |
| Returns a point which has the same X position as this one, but a new Y. | |
| void | setXY (const ValueType newX, const ValueType newY) noexcept |
| Changes the point's x and y co-ordinates. | |
| void | addXY (const ValueType xToAdd, const ValueType yToAdd) noexcept |
| Adds a pair of co-ordinates to this value. | |
| Point | translated (const ValueType xDelta, const ValueType yDelta) const noexcept |
| Returns a point with a given offset from this one. | |
| Point | operator+ (const Point &other) const noexcept |
| Adds two points together. | |
| Point & | operator+= (const Point &other) noexcept |
| Adds another point's co-ordinates to this one. | |
| Point | operator- (const Point &other) const noexcept |
| Subtracts one points from another. | |
| Point & | operator-= (const Point &other) noexcept |
| Subtracts another point's co-ordinates to this one. | |
| Point | operator* (const ValueType multiplier) const noexcept |
| Returns a point whose coordinates are multiplied by a given value. | |
| Point & | operator*= (const ValueType multiplier) noexcept |
| Multiplies the point's co-ordinates by a value. | |
| Point | operator/ (const ValueType divisor) const noexcept |
| Returns a point whose coordinates are divided by a given value. | |
| Point & | operator/= (const ValueType divisor) noexcept |
| Divides the point's co-ordinates by a value. | |
| Point | operator- () const noexcept |
| Returns the inverse of this point. | |
| ValueType | getDistanceFromOrigin () const noexcept |
| Returns the straight-line distance between this point and another one. | |
| ValueType | getDistanceFrom (const Point &other) const noexcept |
| Returns the straight-line distance between this point and another one. | |
| ValueType | getAngleToPoint (const Point &other) const noexcept |
| Returns the angle from this point to another one. | |
| Point | getPointOnCircumference (const float radius, const float angle) const noexcept |
| Taking this point to be the centre of a circle, this returns a point on its circumference. | |
| Point | getPointOnCircumference (const float radiusX, const float radiusY, const float angle) const noexcept |
| Taking this point to be the centre of an ellipse, this returns a point on its circumference. | |
| void | applyTransform (const AffineTransform &transform) noexcept |
| Uses a transform to change the point's co-ordinates. | |
| Point | transformedBy (const AffineTransform &transform) const noexcept |
| Returns the position of this point, if it is transformed by a given AffineTransform. | |
| Point< int > | toInt () const noexcept |
| Casts this point to a Point<int> object. | |
| Point< float > | toFloat () const noexcept |
| Casts this point to a Point<float> object. | |
| Point< double > | toDouble () const noexcept |
| Casts this point to a Point<double> object. | |
| String | toString () const |
| Returns the point as a string in the form "x, y". | |
A pair of (x, y) co-ordinates.
The ValueType template should be a primitive type such as int, float, double, rather than a class.
Creates a point with co-ordinates (0, 0).
Referenced by Point< int >::operator*(), Point< int >::operator+(), Point< int >::operator-(), Point< int >::operator/(), Point< int >::transformedBy(), Point< int >::translated(), Point< int >::withX(), and Point< int >::withY().
Creates a copy of another point.
| Point< ValueType >::Point | ( | const ValueType | initialX, |
| const ValueType | initialY | ||
| ) |
Creates a point from an (x, y) position.
| Point& Point< ValueType >::operator= | ( | const Point< ValueType > & | other ) |
Copies this point from another one.
| bool Point< ValueType >::operator== | ( | const Point< ValueType > & | other ) | const |
| bool Point< ValueType >::operator!= | ( | const Point< ValueType > & | other ) | const |
| bool Point< ValueType >::isOrigin | ( | ) | const |
Returns true if the point is (0, 0).
| ValueType Point< ValueType >::getX | ( | ) | const |
Returns the point's x co-ordinate.
Referenced by Line< ValueType >::findNearestProportionalPositionTo(), Line< ValueType >::getDistanceFromPoint(), and Line< ValueType >::getPointAlongLine().
| ValueType Point< ValueType >::getY | ( | ) | const |
Returns the point's y co-ordinate.
Referenced by Line< ValueType >::findNearestProportionalPositionTo(), Line< ValueType >::getDistanceFromPoint(), and Line< ValueType >::getPointAlongLine().
| void Point< ValueType >::setX | ( | const ValueType | newX ) |
Sets the point's x co-ordinate.
| void Point< ValueType >::setY | ( | const ValueType | newY ) |
Sets the point's y co-ordinate.
Returns a point which has the same Y position as this one, but a new X.
Returns a point which has the same X position as this one, but a new Y.
| void Point< ValueType >::setXY | ( | const ValueType | newX, |
| const ValueType | newY | ||
| ) |
Changes the point's x and y co-ordinates.
| void Point< ValueType >::addXY | ( | const ValueType | xToAdd, |
| const ValueType | yToAdd | ||
| ) |
Adds a pair of co-ordinates to this value.
| Point Point< ValueType >::translated | ( | const ValueType | xDelta, |
| const ValueType | yDelta | ||
| ) | const |
Returns a point with a given offset from this one.
| Point Point< ValueType >::operator+ | ( | const Point< ValueType > & | other ) | const |
Adds two points together.
| Point& Point< ValueType >::operator+= | ( | const Point< ValueType > & | other ) |
Adds another point's co-ordinates to this one.
| Point Point< ValueType >::operator- | ( | const Point< ValueType > & | other ) | const |
Subtracts one points from another.
| Point& Point< ValueType >::operator-= | ( | const Point< ValueType > & | other ) |
Subtracts another point's co-ordinates to this one.
| Point Point< ValueType >::operator* | ( | const ValueType | multiplier ) | const |
Returns a point whose coordinates are multiplied by a given value.
Multiplies the point's co-ordinates by a value.
Returns a point whose coordinates are divided by a given value.
Divides the point's co-ordinates by a value.
Returns the inverse of this point.
| ValueType Point< ValueType >::getDistanceFromOrigin | ( | ) | const |
Returns the straight-line distance between this point and another one.
| ValueType Point< ValueType >::getDistanceFrom | ( | const Point< ValueType > & | other ) | const |
Returns the straight-line distance between this point and another one.
Referenced by Line< ValueType >::getDistanceFromPoint().
| ValueType Point< ValueType >::getAngleToPoint | ( | const Point< ValueType > & | other ) | const |
Returns the angle from this point to another one.
The return value is the number of radians clockwise from the 3 o'clock direction, where this point is the centre and the other point is on the circumference.
| Point Point< ValueType >::getPointOnCircumference | ( | const float | radius, |
| const float | angle | ||
| ) | const |
Taking this point to be the centre of a circle, this returns a point on its circumference.
| radius | the radius of the circle. |
| angle | the angle of the point, in radians clockwise from the 12 o'clock position. |
| Point Point< ValueType >::getPointOnCircumference | ( | const float | radiusX, |
| const float | radiusY, | ||
| const float | angle | ||
| ) | const |
Taking this point to be the centre of an ellipse, this returns a point on its circumference.
| radiusX | the horizontal radius of the circle. |
| radiusY | the vertical radius of the circle. |
| angle | the angle of the point, in radians clockwise from the 12 o'clock position. |
| void Point< ValueType >::applyTransform | ( | const AffineTransform & | transform ) |
Uses a transform to change the point's co-ordinates.
This will only compile if ValueType = float!
| Point Point< ValueType >::transformedBy | ( | const AffineTransform & | transform ) | const |
Returns the position of this point, if it is transformed by a given AffineTransform.
Casts this point to a Point<int> object.
Casts this point to a Point<float> object.
Casts this point to a Point<double> object.
Returns the point as a string in the form "x, y".