A pair of (x, y) coordinates. More...
#include <juce_Point.h>


Public Types | |
| using | FloatType = TypeHelpers::SmallestFloatType< ValueType > |
| This type will be double if the Point's type is double, otherwise it will be float. | |
Public Member Functions | |
| constexpr | Point ()=default |
| Creates a point at the origin. | |
| constexpr | Point (const Point &)=default |
| Creates a copy of another point. | |
| constexpr | Point (ValueType initialX, ValueType initialY) noexcept |
| Creates a point from an (x, y) position. | |
| void | addXY (ValueType xToAdd, ValueType yToAdd) noexcept |
| Adds a pair of coordinates to this value. | |
| void | applyTransform (const AffineTransform &transform) noexcept |
| Uses a transform to change the point's coordinates. | |
| FloatType | getAngleToPoint (Point other) const noexcept |
| Returns the angle from this point to another one. | |
| ValueType | getDistanceFrom (Point other) const noexcept |
| Returns the straight-line distance between this point and another one. | |
| ValueType | getDistanceFromOrigin () const noexcept |
| Returns the straight-line distance between this point and the origin. | |
| constexpr ValueType | getDistanceSquaredFrom (Point other) const noexcept |
| Returns the square of the straight-line distance between this point and another one. | |
| constexpr ValueType | getDistanceSquaredFromOrigin () const noexcept |
| Returns the square of the straight-line distance between this point and the origin. | |
| constexpr FloatType | getDotProduct (Point other) const noexcept |
| Returns the dot-product of two points (x1 * x2 + y1 * y2). | |
| 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. | |
| constexpr ValueType | getX () const noexcept |
| Returns the point's x coordinate. | |
| constexpr ValueType | getY () const noexcept |
| Returns the point's y coordinate. | |
| constexpr bool | isFinite () const noexcept |
| Returns true if the coordinates are finite values. | |
| constexpr bool | isOrigin () const noexcept |
| Returns true if the point is (0, 0). | |
| constexpr bool | operator!= (Point other) const noexcept |
| template<typename OtherType > | |
| constexpr Point | operator* (OtherType multiplier) const noexcept |
| Returns a point whose coordinates are multiplied by a given scalar value. | |
| template<typename OtherType > | |
| constexpr Point | operator* (Point< OtherType > other) const noexcept |
| Multiplies two points together. | |
| template<typename FloatType > | |
| Point & | operator*= (FloatType multiplier) noexcept |
| Multiplies the point's coordinates by a scalar value. | |
| template<typename OtherType > | |
| Point & | operator*= (Point< OtherType > other) noexcept |
| Multiplies another point's coordinates to this one. | |
| constexpr Point | operator+ (Point other) const noexcept |
| Adds two points together. | |
| Point & | operator+= (Point other) noexcept |
| Adds another point's coordinates to this one. | |
| constexpr Point | operator- () const noexcept |
| Returns the inverse of this point. | |
| 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 > | |
| constexpr Point | operator/ (OtherType divisor) const noexcept |
| Returns a point whose coordinates are divided by a given scalar value. | |
| template<typename OtherType > | |
| constexpr Point | operator/ (Point< OtherType > other) const noexcept |
| Divides one point by another. | |
| template<typename FloatType > | |
| Point & | operator/= (FloatType divisor) noexcept |
| Divides the point's coordinates by a scalar value. | |
| template<typename OtherType > | |
| Point & | operator/= (Point< OtherType > other) noexcept |
| Divides this point's coordinates by another. | |
| Point & | operator= (const Point &)=default |
| Copies this point from another one. | |
| constexpr bool | operator== (Point other) const noexcept |
| template<typename T = ValueType, std::enable_if_t< std::is_floating_point_v< T >, int > = 0> | |
| 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. | |
| constexpr Point< int > | roundToInt () const noexcept |
| Casts this point to a Point<int> object using roundToInt() to convert the values. | |
| void | setX (ValueType newX) noexcept |
| Sets the point's x coordinate. | |
| void | setXY (ValueType newX, ValueType newY) noexcept |
| Changes the point's x and y coordinates. | |
| void | setY (ValueType newY) noexcept |
| Sets the point's y coordinate. | |
| constexpr Point< double > | toDouble () const noexcept |
| Casts this point to a Point<double> object. | |
| constexpr Point< float > | toFloat () const noexcept |
| Casts this point to a Point<float> object. | |
| constexpr Point< int > | toInt () const noexcept |
| Casts this point to a Point<int> object. | |
| String | toString () const |
| Returns the point as a string in the form "x, y". | |
| Point | transformedBy (const AffineTransform &transform) const noexcept |
| Returns the position of this point, if it is transformed by a given AffineTransform. | |
| constexpr Point | translated (ValueType deltaX, ValueType deltaY) const noexcept |
| Returns a point with a given offset from this one. | |
| constexpr Point | withX (ValueType newX) const noexcept |
| Returns a point which has the same Y position as this one, but a new X. | |
| constexpr Point | withY (ValueType newY) const noexcept |
| Returns a point which has the same X position as this one, but a new 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.
@tags{Graphics}
| using juce::Point< ValueType >::FloatType = TypeHelpers::SmallestFloatType<ValueType> |
This type will be double if the Point's type is double, otherwise it will be float.
|
constexprdefault |
Creates a point at the origin.
Referenced by juce::Point< ValueType >::isOrigin(), juce::Point< ValueType >::operator*(), juce::Point< ValueType >::operator*(), juce::Point< ValueType >::operator+(), juce::Point< ValueType >::operator-(), juce::Point< ValueType >::operator-(), juce::Point< ValueType >::operator/(), juce::Point< ValueType >::operator/(), juce::Point< ValueType >::rotatedAboutOrigin(), juce::Point< ValueType >::transformedBy(), juce::Point< ValueType >::translated(), juce::Point< ValueType >::withX(), and juce::Point< ValueType >::withY().
|
constexprdefault |
Creates a copy of another point.
|
inlineconstexprnoexcept |
Creates a point from an (x, y) position.
|
inlinenoexcept |
Adds a pair of coordinates to this value.
References juce::Point< ValueType >::x, and juce::Point< ValueType >::y.
|
inlinenoexcept |
Uses a transform to change the point's coordinates.
This will only compile if ValueType = float!
References juce::Point< ValueType >::x, and juce::Point< ValueType >::y.
|
inlinenoexcept |
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
References juce::Point< ValueType >::x, and juce::Point< ValueType >::y.
|
inlinenoexcept |
Returns the straight-line distance between this point and another one.
References juce::juce_hypot(), juce::Point< ValueType >::x, and juce::Point< ValueType >::y.
Referenced by juce::detail::MouseInputSourceImpl::registerMouseDrag().
|
inlinenoexcept |
Returns the straight-line distance between this point and the origin.
References juce::juce_hypot(), juce::Point< ValueType >::x, and juce::Point< ValueType >::y.
|
inlineconstexprnoexcept |
Returns the square of the straight-line distance between this point and another one.
|
inlineconstexprnoexcept |
Returns the square of the straight-line distance between this point and the origin.
References juce::Point< ValueType >::x, and juce::Point< ValueType >::y.
|
inlineconstexprnoexcept |
Returns the dot-product of two points (x1 * x2 + y1 * y2).
References juce::Point< ValueType >::x, and juce::Point< ValueType >::y.
|
inlinenoexcept |
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. |
References juce::Point< ValueType >::x, and juce::Point< ValueType >::y.
|
inlinenoexcept |
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. |
References juce::Point< ValueType >::x, and juce::Point< ValueType >::y.
|
inlineconstexprnoexcept |
Returns the point's x coordinate.
References juce::Point< ValueType >::x.
|
inlineconstexprnoexcept |
Returns the point's y coordinate.
References juce::Point< ValueType >::y.
|
inlineconstexprnoexcept |
Returns true if the coordinates are finite values.
References juce::juce_isfinite(), juce::Point< ValueType >::x, and juce::Point< ValueType >::y.
|
inlineconstexprnoexcept |
Returns true if the point is (0, 0).
References juce::Point< ValueType >::Point(), and juce::Point< ValueType >::operator==().
Referenced by juce::detail::MouseInputSourceImpl::enableUnboundedMouseMovement(), juce::detail::MouseInputSourceImpl::handleUnboundedDrag(), and juce::detail::MouseInputSourceImpl::showMouseCursor().
|
inlineconstexprnoexcept |
References juce::Point< ValueType >::operator==().
|
inlineconstexprnoexcept |
Returns a point whose coordinates are multiplied by a given scalar value.
References juce::Point< ValueType >::Point(), juce::Point< ValueType >::x, and juce::Point< ValueType >::y.
|
inlineconstexprnoexcept |
Multiplies two points together.
References juce::Point< ValueType >::Point(), juce::Point< ValueType >::x, and juce::Point< ValueType >::y.
|
inlinenoexcept |
Multiplies the point's coordinates by a scalar value.
References juce::Point< ValueType >::x, and juce::Point< ValueType >::y.
|
inlinenoexcept |
Multiplies another point's coordinates to this one.
|
inlineconstexprnoexcept |
Adds two points together.
References juce::Point< ValueType >::Point(), juce::Point< ValueType >::x, and juce::Point< ValueType >::y.
|
inlinenoexcept |
Adds another point's coordinates to this one.
References juce::Point< ValueType >::x, and juce::Point< ValueType >::y.
|
inlineconstexprnoexcept |
Returns the inverse of this point.
References juce::Point< ValueType >::Point(), juce::Point< ValueType >::x, and juce::Point< ValueType >::y.
|
inlineconstexprnoexcept |
Subtracts one points from another.
References juce::Point< ValueType >::Point(), juce::Point< ValueType >::x, and juce::Point< ValueType >::y.
|
inlinenoexcept |
Subtracts another point's coordinates to this one.
References juce::Point< ValueType >::x, and juce::Point< ValueType >::y.
|
inlineconstexprnoexcept |
Returns a point whose coordinates are divided by a given scalar value.
References juce::Point< ValueType >::Point(), juce::Point< ValueType >::x, and juce::Point< ValueType >::y.
|
inlineconstexprnoexcept |
Divides one point by another.
References juce::Point< ValueType >::Point(), juce::Point< ValueType >::x, and juce::Point< ValueType >::y.
|
inlinenoexcept |
Divides the point's coordinates by a scalar value.
References juce::Point< ValueType >::x, and juce::Point< ValueType >::y.
|
inlinenoexcept |
Divides this point's coordinates by another.
|
default |
Copies this point from another one.
|
inlineconstexprnoexcept |
Referenced by juce::Point< ValueType >::isOrigin(), and juce::Point< ValueType >::operator!=().
|
inlinenoexcept |
Returns the point that would be reached by rotating this point clockwise about the origin by the specified angle.
References juce::Point< ValueType >::Point(), juce::Point< ValueType >::x, and juce::Point< ValueType >::y.
|
inlineconstexprnoexcept |
Casts this point to a Point<int> object using roundToInt() to convert the values.
References juce::roundToInt(), juce::Point< ValueType >::x, and juce::Point< ValueType >::y.
Referenced by juce::detail::ComponentHelpers::hitTest().
|
inlinenoexcept |
Sets the point's x coordinate.
References juce::Point< ValueType >::x.
|
inlinenoexcept |
Changes the point's x and y coordinates.
References juce::Point< ValueType >::x, and juce::Point< ValueType >::y.
|
inlinenoexcept |
Sets the point's y coordinate.
References juce::Point< ValueType >::y.
|
inlineconstexprnoexcept |
Casts this point to a Point<double> object.
References juce::Point< ValueType >::x, and juce::Point< ValueType >::y.
|
inlineconstexprnoexcept |
Casts this point to a Point<float> object.
References juce::Point< ValueType >::x, and juce::Point< ValueType >::y.
Referenced by juce::RenderingHelpers::SavedStateBase< SavedStateType >::fillRectList().
|
inlineconstexprnoexcept |
Casts this point to a Point<int> object.
References juce::Point< ValueType >::x, and juce::Point< ValueType >::y.
|
inline |
Returns the point as a string in the form "x, y".
References juce::Point< ValueType >::x, and juce::Point< ValueType >::y.
|
inlinenoexcept |
Returns the position of this point, if it is transformed by a given AffineTransform.
References juce::Point< ValueType >::Point(), juce::Point< ValueType >::x, and juce::Point< ValueType >::y.
|
inlineconstexprnoexcept |
Returns a point with a given offset from this one.
References juce::Point< ValueType >::Point(), juce::Point< ValueType >::x, and juce::Point< ValueType >::y.
|
inlineconstexprnoexcept |
Returns a point which has the same Y position as this one, but a new X.
References juce::Point< ValueType >::Point(), and juce::Point< ValueType >::y.
|
inlineconstexprnoexcept |
Returns a point which has the same X position as this one, but a new Y.
References juce::Point< ValueType >::Point(), and juce::Point< ValueType >::x.
| ValueType juce::Point< ValueType >::x {} |
The point's X coordinate.
Referenced by juce::RenderingHelpers::GradientPixelIterators::Radial::Radial(), juce::Point< ValueType >::addXY(), juce::Point< ValueType >::applyTransform(), juce::detail::MouseInputSourceImpl::RecentMouseDown::canBePartOfMultipleClickWith(), juce::Point< ValueType >::getAngleToPoint(), juce::Point< ValueType >::getDistanceFrom(), juce::Point< ValueType >::getDistanceFromOrigin(), juce::Point< ValueType >::getDistanceSquaredFromOrigin(), juce::Point< ValueType >::getDotProduct(), juce::Point< ValueType >::getPointOnCircumference(), juce::Point< ValueType >::getPointOnCircumference(), juce::Point< ValueType >::getX(), juce::Point< ValueType >::isFinite(), juce::Point< ValueType >::operator*(), juce::Point< ValueType >::operator*(), juce::Point< ValueType >::operator*=(), juce::Point< ValueType >::operator+(), juce::Point< ValueType >::operator+=(), juce::Point< ValueType >::operator-(), juce::Point< ValueType >::operator-(), juce::Point< ValueType >::operator-=(), juce::Point< ValueType >::operator/(), juce::Point< ValueType >::operator/(), juce::Point< ValueType >::operator/=(), juce::Point< ValueType >::rotatedAboutOrigin(), juce::Point< ValueType >::roundToInt(), juce::Point< ValueType >::setX(), juce::Point< ValueType >::setXY(), juce::Point< ValueType >::toDouble(), juce::Point< ValueType >::toFloat(), juce::Point< ValueType >::toInt(), juce::Point< ValueType >::toString(), juce::Point< ValueType >::transformedBy(), juce::RenderingHelpers::ClipRegions::EdgeTableRegion< SavedStateType >::translate(), juce::Point< ValueType >::translated(), and juce::Point< ValueType >::withY().
| ValueType juce::Point< ValueType >::y {} |
The point's Y coordinate.
Referenced by juce::Point< ValueType >::addXY(), juce::Point< ValueType >::applyTransform(), juce::detail::MouseInputSourceImpl::RecentMouseDown::canBePartOfMultipleClickWith(), juce::Point< ValueType >::getAngleToPoint(), juce::Point< ValueType >::getDistanceFrom(), juce::Point< ValueType >::getDistanceFromOrigin(), juce::Point< ValueType >::getDistanceSquaredFromOrigin(), juce::Point< ValueType >::getDotProduct(), juce::Point< ValueType >::getPointOnCircumference(), juce::Point< ValueType >::getPointOnCircumference(), juce::Point< ValueType >::getY(), juce::Point< ValueType >::isFinite(), juce::Point< ValueType >::operator*(), juce::Point< ValueType >::operator*(), juce::Point< ValueType >::operator*=(), juce::Point< ValueType >::operator+(), juce::Point< ValueType >::operator+=(), juce::Point< ValueType >::operator-(), juce::Point< ValueType >::operator-(), juce::Point< ValueType >::operator-=(), juce::Point< ValueType >::operator/(), juce::Point< ValueType >::operator/(), juce::Point< ValueType >::operator/=(), juce::Point< ValueType >::rotatedAboutOrigin(), juce::Point< ValueType >::roundToInt(), juce::Point< ValueType >::setXY(), juce::Point< ValueType >::setY(), juce::Point< ValueType >::toDouble(), juce::Point< ValueType >::toFloat(), juce::Point< ValueType >::toInt(), juce::Point< ValueType >::toString(), juce::Point< ValueType >::transformedBy(), juce::RenderingHelpers::ClipRegions::EdgeTableRegion< SavedStateType >::translate(), juce::Point< ValueType >::translated(), and juce::Point< ValueType >::withX().