JUCE
|
A pair of (x, y) coordinates. More...
#include <juce_Point.h>
Public Types | |
using | FloatType = typename TypeHelpers::SmallestFloatType<ValueType>::type |
This type will be double if the Point's type is double, otherwise it will be float. | |
Public Member Functions | |
JUCE_CONSTEXPR | Point ()=default |
Creates a point at the origin. | |
JUCE_CONSTEXPR | Point (const Point &)=default |
Creates a copy of another point. | |
JUCE_CONSTEXPR | Point (ValueType initialX, ValueType initialY) noexcept |
Creates a point from an (x, y) position. | |
Point & | operator= (const Point &)=default |
Copies this point from another one. | |
JUCE_CONSTEXPR bool | operator== (Point other) const noexcept |
JUCE_CONSTEXPR bool | operator!= (Point other) const noexcept |
JUCE_CONSTEXPR bool | isOrigin () const noexcept |
Returns true if the point is (0, 0). | |
JUCE_CONSTEXPR bool | isFinite () const noexcept |
Returns true if the coordinates are finite values. | |
JUCE_CONSTEXPR ValueType | getX () const noexcept |
Returns the point's x coordinate. | |
JUCE_CONSTEXPR ValueType | getY () const noexcept |
Returns the point's y coordinate. | |
void | setX (ValueType newX) noexcept |
Sets the point's x coordinate. | |
void | setY (ValueType newY) noexcept |
Sets the point's y coordinate. | |
JUCE_CONSTEXPR Point | withX (ValueType newX) const noexcept |
Returns a point which has the same Y position as this one, but a new X. | |
JUCE_CONSTEXPR Point | withY (ValueType newY) const noexcept |
Returns a point which has the same X position as this one, but a new Y. | |
void | setXY (ValueType newX, ValueType newY) noexcept |
Changes the point's x and y coordinates. | |
void | addXY (ValueType xToAdd, ValueType yToAdd) noexcept |
Adds a pair of coordinates to this value. | |
JUCE_CONSTEXPR Point | translated (ValueType deltaX, ValueType deltaY) const noexcept |
Returns a point with a given offset from this one. | |
JUCE_CONSTEXPR Point | operator+ (Point other) const noexcept |
Adds two points together. | |
Point & | operator+= (Point other) noexcept |
Adds another point's coordinates to this one. | |
JUCE_CONSTEXPR Point | operator- (Point other) const noexcept |
Subtracts one points from another. | |
Point & | operator-= (Point other) noexcept |
Subtracts another point's coordinates to this one. | |
template<typename OtherType> | |
JUCE_CONSTEXPR Point | operator* (Point< OtherType > other) const noexcept |
Multiplies two points together. | |
template<typename OtherType> | |
Point & | operator*= (Point< OtherType > other) noexcept |
Multiplies another point's coordinates to this one. | |
template<typename OtherType> | |
JUCE_CONSTEXPR Point | operator/ (Point< OtherType > other) const noexcept |
Divides one point by another. | |
template<typename OtherType> | |
Point & | operator/= (Point< OtherType > other) noexcept |
Divides this point's coordinates by another. | |
template<typename FloatType> | |
JUCE_CONSTEXPR Point | operator* (FloatType multiplier) const noexcept |
Returns a point whose coordinates are multiplied by a given scalar value. | |
template<typename FloatType> | |
JUCE_CONSTEXPR Point | operator/ (FloatType divisor) const noexcept |
Returns a point whose coordinates are divided by a given scalar value. | |
template<typename FloatType> | |
Point & | operator*= (FloatType multiplier) noexcept |
Multiplies the point's coordinates by a scalar value. | |
template<typename FloatType> | |
Point & | operator/= (FloatType divisor) noexcept |
Divides the point's coordinates by a scalar value. | |
JUCE_CONSTEXPR Point | operator- () const noexcept |
Returns the inverse of this point. | |
ValueType | getDistanceFromOrigin () const noexcept |
Returns the straight-line distance between this point and the origin. | |
ValueType | getDistanceFrom (Point other) const noexcept |
Returns the straight-line distance between this point and another one. | |
JUCE_CONSTEXPR ValueType | getDistanceSquaredFromOrigin () const noexcept |
Returns the square of the straight-line distance between this point and the origin. | |
JUCE_CONSTEXPR ValueType | getDistanceSquaredFrom (Point other) const noexcept |
Returns the square of the straight-line distance between this point and another one. | |
FloatType | getAngleToPoint (Point other) const noexcept |
Returns the angle from this point to another one. | |
Point | rotatedAboutOrigin (ValueType angleRadians) const noexcept |
Returns the point that would be reached by rotating this point clockwise about the origin by the specified angle. | |
Point< FloatType > | getPointOnCircumference (float radius, float angle) const noexcept |
Taking this point to be the centre of a circle, this returns a point on its circumference. | |
Point< FloatType > | getPointOnCircumference (float radiusX, float radiusY, float angle) const noexcept |
Taking this point to be the centre of an ellipse, this returns a point on its circumference. | |
JUCE_CONSTEXPR FloatType | getDotProduct (Point other) const noexcept |
Returns the dot-product of two points (x1 * x2 + y1 * y2). | |
void | applyTransform (const AffineTransform &transform) noexcept |
Uses a transform to change the point's coordinates. | |
Point | transformedBy (const AffineTransform &transform) const noexcept |
Returns the position of this point, if it is transformed by a given AffineTransform. | |
JUCE_CONSTEXPR Point< int > | toInt () const noexcept |
Casts this point to a Point<int> object. | |
JUCE_CONSTEXPR Point< float > | toFloat () const noexcept |
Casts this point to a Point<float> object. | |
JUCE_CONSTEXPR Point< double > | toDouble () const noexcept |
Casts this point to a Point<double> object. | |
JUCE_CONSTEXPR Point< int > | roundToInt () const noexcept |
Casts this point to a Point<int> object using roundToInt() to convert the values. | |
String | toString () const |
Returns the point as a string in the form "x, y". | |
Public Attributes | |
ValueType | x {} |
The point's X coordinate. | |
ValueType | y {} |
The point's Y coordinate. | |
A pair of (x, y) coordinates.
The ValueType template should be a primitive type such as int, float, double, rather than a class.
using Point< ValueType >::FloatType = typename TypeHelpers::SmallestFloatType<ValueType>::type |
This type will be double if the Point's type is double, otherwise it will be float.
|
default |
Creates a point at the origin.
References JUCE_CONSTEXPR.
Referenced by getPointOnCircumference(), getPointOnCircumference(), operator*(), operator*=(), operator/(), operator/=(), roundToInt(), toDouble(), toFloat(), and toInt().
|
default |
Creates a copy of another point.
References JUCE_CONSTEXPR, and Point.
|
noexcept |
Creates a point from an (x, y) position.
References JUCE_CONSTEXPR, x, and y.
|
default |
Copies this point from another one.
References Point.
|
noexcept |
References JUCE_CONSTEXPR, Point, x, and y.
|
noexcept |
References JUCE_CONSTEXPR, Point, x, and y.
|
noexcept |
Returns true if the point is (0, 0).
References JUCE_CONSTEXPR, x, and y.
|
noexcept |
Returns true if the coordinates are finite values.
References JUCE_CONSTEXPR, juce_isfinite(), x, and y.
|
noexcept |
Returns the point's x coordinate.
References JUCE_CONSTEXPR, and x.
|
noexcept |
Returns the point's y coordinate.
References JUCE_CONSTEXPR, and y.
|
noexcept |
Sets the point's x coordinate.
References x.
|
noexcept |
Sets the point's y coordinate.
References y.
|
noexcept |
Returns a point which has the same Y position as this one, but a new X.
References JUCE_CONSTEXPR, Point, and y.
|
noexcept |
Returns a point which has the same X position as this one, but a new Y.
References JUCE_CONSTEXPR, Point, and x.
|
noexcept |
|
noexcept |
|
noexcept |
Returns a point with a given offset from this one.
References JUCE_CONSTEXPR, Point, x, and y.
|
noexcept |
Adds two points together.
References JUCE_CONSTEXPR, Point, x, and y.
|
noexcept |
Subtracts one points from another.
References JUCE_CONSTEXPR, Point, x, and y.
|
noexcept |
Multiplies two points together.
References JUCE_CONSTEXPR, Point, Point(), x, and y.
|
noexcept |
Divides one point by another.
References JUCE_CONSTEXPR, Point, Point(), x, and y.
|
noexcept |
Returns a point whose coordinates are multiplied by a given scalar value.
References JUCE_CONSTEXPR, Point, x, and y.
|
noexcept |
Returns a point whose coordinates are divided by a given scalar value.
References JUCE_CONSTEXPR, Point, x, and y.
|
noexcept |
Returns the inverse of this point.
References JUCE_CONSTEXPR, Point, x, and y.
|
noexcept |
Returns the straight-line distance between this point and the origin.
References juce_hypot(), x, and y.
|
noexcept |
Returns the straight-line distance between this point and another one.
References juce_hypot(), Point, x, and y.
|
noexcept |
Returns the square of the straight-line distance between this point and the origin.
References JUCE_CONSTEXPR, x, and y.
|
noexcept |
Returns the square of the straight-line distance between this point and another one.
References JUCE_CONSTEXPR, and Point.
|
noexcept |
Returns the angle from this point to another one.
Taking this point to be the centre of a circle, and the other point being a position on the circumference, the return value is the number of radians clockwise from the 12 o'clock direction. So 12 o'clock = 0, 3 o'clock = Pi/2, 6 o'clock = Pi, 9 o'clock = -Pi/2
|
noexcept |
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. |
|
noexcept |
Returns the dot-product of two points (x1 * x2 + y1 * y2).
References JUCE_CONSTEXPR, Point, x, and y.
|
noexcept |
Uses a transform to change the point's coordinates.
This will only compile if ValueType = float!
|
noexcept |
Returns the position of this point, if it is transformed by a given AffineTransform.
|
noexcept |
Casts this point to a Point<int> object.
References JUCE_CONSTEXPR, Point(), x, and y.
|
noexcept |
Casts this point to a Point<float> object.
References JUCE_CONSTEXPR, Point(), x, and y.
|
noexcept |
Casts this point to a Point<double> object.
References JUCE_CONSTEXPR, Point, Point(), x, and y.
|
noexcept |
Casts this point to a Point<int> object using roundToInt() to convert the values.
References JUCE_CONSTEXPR, Point(), x, and y.
ValueType Point< ValueType >::x {} |
The point's X coordinate.
Referenced by addXY(), applyTransform(), getAngleToPoint(), getDistanceFrom(), getDistanceFromOrigin(), getDistanceSquaredFromOrigin(), getDotProduct(), getPointOnCircumference(), getPointOnCircumference(), getX(), isFinite(), isOrigin(), operator!=(), operator*(), operator*(), operator*=(), operator+(), operator+=(), operator-(), operator-(), operator-=(), operator/(), operator/(), operator/=(), operator==(), Point(), rotatedAboutOrigin(), roundToInt(), setX(), setXY(), toDouble(), toFloat(), toInt(), toString(), transformedBy(), translated(), and withY().
ValueType Point< ValueType >::y {} |
The point's Y coordinate.
Referenced by addXY(), applyTransform(), getAngleToPoint(), getDistanceFrom(), getDistanceFromOrigin(), getDistanceSquaredFromOrigin(), getDotProduct(), getPointOnCircumference(), getPointOnCircumference(), getY(), isFinite(), isOrigin(), operator!=(), operator*(), operator*(), operator*=(), operator+(), operator+=(), operator-(), operator-(), operator-=(), operator/(), operator/(), operator/=(), operator==(), Point(), rotatedAboutOrigin(), roundToInt(), setXY(), setY(), toDouble(), toFloat(), toInt(), toString(), transformedBy(), translated(), and withX().