A pair of (x, y) coordinates. More...

Public Types

typedef TypeHelpers::SmallestFloatType< ValueType >::type FloatType
 This type will be double if the Point's type is double, otherwise it will be float. More...
 

Public Member Functions

JUCE_CONSTEXPR Point () noexcept
 Creates a point at the origin. More...
 
JUCE_CONSTEXPR Point (const Point &other) noexcept
 Creates a copy of another point. More...
 
JUCE_CONSTEXPR Point (ValueType initialX, ValueType initialY) noexcept
 Creates a point from an (x, y) position. More...
 
Pointoperator= (const Point &other) noexcept
 Copies this point from another one. More...
 
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). More...
 
JUCE_CONSTEXPR bool isFinite () const noexcept
 Returns true if the coordinates are finite values. More...
 
JUCE_CONSTEXPR ValueType getX () const noexcept
 Returns the point's x coordinate. More...
 
JUCE_CONSTEXPR ValueType getY () const noexcept
 Returns the point's y coordinate. More...
 
void setX (ValueType newX) noexcept
 Sets the point's x coordinate. More...
 
void setY (ValueType newY) noexcept
 Sets the point's y coordinate. More...
 
JUCE_CONSTEXPR Point withX (ValueType newX) const noexcept
 Returns a point which has the same Y position as this one, but a new X. More...
 
JUCE_CONSTEXPR Point withY (ValueType newY) const noexcept
 Returns a point which has the same X position as this one, but a new Y. More...
 
void setXY (ValueType newX, ValueType newY) noexcept
 Changes the point's x and y coordinates. More...
 
void addXY (ValueType xToAdd, ValueType yToAdd) noexcept
 Adds a pair of coordinates to this value. More...
 
JUCE_CONSTEXPR Point translated (ValueType deltaX, ValueType deltaY) const noexcept
 Returns a point with a given offset from this one. More...
 
JUCE_CONSTEXPR Point operator+ (Point other) const noexcept
 Adds two points together. More...
 
Pointoperator+= (Point other) noexcept
 Adds another point's coordinates to this one. More...
 
JUCE_CONSTEXPR Point operator- (Point other) const noexcept
 Subtracts one points from another. More...
 
Pointoperator-= (Point other) noexcept
 Subtracts another point's coordinates to this one. More...
 
template<typename OtherType >
JUCE_CONSTEXPR Point operator* (Point< OtherType > other) const noexcept
 Multiplies two points together. More...
 
template<typename OtherType >
Pointoperator*= (Point< OtherType > other) noexcept
 Multiplies another point's coordinates to this one. More...
 
template<typename OtherType >
JUCE_CONSTEXPR Point operator/ (Point< OtherType > other) const noexcept
 Divides one point by another. More...
 
template<typename OtherType >
Pointoperator/= (Point< OtherType > other) noexcept
 Divides this point's coordinates by another. More...
 
template<typename FloatType >
JUCE_CONSTEXPR Point operator* (FloatType multiplier) const noexcept
 Returns a point whose coordinates are multiplied by a given scalar value. More...
 
template<typename FloatType >
JUCE_CONSTEXPR Point operator/ (FloatType divisor) const noexcept
 Returns a point whose coordinates are divided by a given scalar value. More...
 
template<typename FloatType >
Pointoperator*= (FloatType multiplier) noexcept
 Multiplies the point's coordinates by a scalar value. More...
 
template<typename FloatType >
Pointoperator/= (FloatType divisor) noexcept
 Divides the point's coordinates by a scalar value. More...
 
JUCE_CONSTEXPR Point operator- () const noexcept
 Returns the inverse of this point. More...
 
ValueType getDistanceFromOrigin () const noexcept
 Returns the straight-line distance between this point and the origin. More...
 
ValueType getDistanceFrom (Point other) const noexcept
 Returns the straight-line distance between this point and another one. More...
 
JUCE_CONSTEXPR ValueType getDistanceSquaredFromOrigin () const noexcept
 Returns the square of the straight-line distance between this point and the origin. More...
 
JUCE_CONSTEXPR ValueType getDistanceSquaredFrom (Point other) const noexcept
 Returns the square of the straight-line distance between this point and another one. More...
 
FloatType getAngleToPoint (Point other) const noexcept
 Returns the angle from this point to another one. More...
 
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. More...
 
Point< FloatTypegetPointOnCircumference (float radius, float angle) const noexcept
 Taking this point to be the centre of a circle, this returns a point on its circumference. More...
 
Point< FloatTypegetPointOnCircumference (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. More...
 
JUCE_CONSTEXPR FloatType getDotProduct (Point other) const noexcept
 Returns the dot-product of two points (x1 * x2 + y1 * y2). More...
 
void applyTransform (const AffineTransform &transform) noexcept
 Uses a transform to change the point's coordinates. More...
 
Point transformedBy (const AffineTransform &transform) const noexcept
 Returns the position of this point, if it is transformed by a given AffineTransform. More...
 
JUCE_CONSTEXPR Point< int > toInt () const noexcept
 Casts this point to a Point<int> object. More...
 
JUCE_CONSTEXPR Point< float > toFloat () const noexcept
 Casts this point to a Point<float> object. More...
 
JUCE_CONSTEXPR Point< double > toDouble () const noexcept
 Casts this point to a Point<double> object. More...
 
JUCE_CONSTEXPR Point< int > roundToInt () const noexcept
 Casts this point to a Point<int> object using roundToInt() to convert the values. More...
 
String toString () const
 Returns the point as a string in the form "x, y". More...
 

Public Attributes

ValueType x
 The point's X coordinate. More...
 
ValueType y
 The point's Y coordinate. More...
 

Detailed Description

template<typename ValueType>
class Point< ValueType >

A pair of (x, y) coordinates.

The ValueType template should be a primitive type such as int, float, double, rather than a class.

See also
Line, Path, AffineTransform

Member Typedef Documentation

◆ FloatType

template<typename ValueType>
typedef TypeHelpers::SmallestFloatType<ValueType>::type Point< ValueType >::FloatType

This type will be double if the Point's type is double, otherwise it will be float.

Constructor & Destructor Documentation

◆ Point() [1/3]

◆ Point() [2/3]

template<typename ValueType>
JUCE_CONSTEXPR Point< ValueType >::Point ( const Point< ValueType > &  other)
noexcept

Creates a copy of another point.

◆ Point() [3/3]

template<typename ValueType>
JUCE_CONSTEXPR Point< ValueType >::Point ( ValueType  initialX,
ValueType  initialY 
)
noexcept

Creates a point from an (x, y) position.

Member Function Documentation

◆ operator=()

template<typename ValueType>
Point& Point< ValueType >::operator= ( const Point< ValueType > &  other)
noexcept

Copies this point from another one.

◆ operator==()

template<typename ValueType>
JUCE_CONSTEXPR bool Point< ValueType >::operator== ( Point< ValueType >  other) const
noexcept

◆ operator!=()

template<typename ValueType>
JUCE_CONSTEXPR bool Point< ValueType >::operator!= ( Point< ValueType >  other) const
noexcept

◆ isOrigin()

template<typename ValueType>
JUCE_CONSTEXPR bool Point< ValueType >::isOrigin ( ) const
noexcept

Returns true if the point is (0, 0).

◆ isFinite()

template<typename ValueType>
JUCE_CONSTEXPR bool Point< ValueType >::isFinite ( ) const
noexcept

Returns true if the coordinates are finite values.

◆ getX()

template<typename ValueType>
JUCE_CONSTEXPR ValueType Point< ValueType >::getX ( ) const
noexcept

Returns the point's x coordinate.

◆ getY()

template<typename ValueType>
JUCE_CONSTEXPR ValueType Point< ValueType >::getY ( ) const
noexcept

Returns the point's y coordinate.

◆ setX()

template<typename ValueType>
void Point< ValueType >::setX ( ValueType  newX)
noexcept

Sets the point's x coordinate.

◆ setY()

template<typename ValueType>
void Point< ValueType >::setY ( ValueType  newY)
noexcept

Sets the point's y coordinate.

◆ withX()

template<typename ValueType>
JUCE_CONSTEXPR Point Point< ValueType >::withX ( ValueType  newX) const
noexcept

Returns a point which has the same Y position as this one, but a new X.

Referenced by Line< ValueType >::withShortenedEnd().

◆ withY()

template<typename ValueType>
JUCE_CONSTEXPR Point Point< ValueType >::withY ( ValueType  newY) const
noexcept

Returns a point which has the same X position as this one, but a new Y.

Referenced by Line< ValueType >::withShortenedEnd().

◆ setXY()

template<typename ValueType>
void Point< ValueType >::setXY ( ValueType  newX,
ValueType  newY 
)
noexcept

Changes the point's x and y coordinates.

◆ addXY()

template<typename ValueType>
void Point< ValueType >::addXY ( ValueType  xToAdd,
ValueType  yToAdd 
)
noexcept

Adds a pair of coordinates to this value.

◆ translated()

template<typename ValueType>
JUCE_CONSTEXPR Point Point< ValueType >::translated ( ValueType  deltaX,
ValueType  deltaY 
) const
noexcept

Returns a point with a given offset from this one.

◆ operator+()

template<typename ValueType>
JUCE_CONSTEXPR Point Point< ValueType >::operator+ ( Point< ValueType >  other) const
noexcept

Adds two points together.

◆ operator+=()

template<typename ValueType>
Point& Point< ValueType >::operator+= ( Point< ValueType >  other)
noexcept

Adds another point's coordinates to this one.

◆ operator-() [1/2]

template<typename ValueType>
JUCE_CONSTEXPR Point Point< ValueType >::operator- ( Point< ValueType >  other) const
noexcept

Subtracts one points from another.

◆ operator-=()

template<typename ValueType>
Point& Point< ValueType >::operator-= ( Point< ValueType >  other)
noexcept

Subtracts another point's coordinates to this one.

◆ operator*() [1/2]

template<typename ValueType>
template<typename OtherType >
JUCE_CONSTEXPR Point Point< ValueType >::operator* ( Point< OtherType >  other) const
noexcept

Multiplies two points together.

◆ operator*=() [1/2]

template<typename ValueType>
template<typename OtherType >
Point& Point< ValueType >::operator*= ( Point< OtherType >  other)
noexcept

Multiplies another point's coordinates to this one.

◆ operator/() [1/2]

template<typename ValueType>
template<typename OtherType >
JUCE_CONSTEXPR Point Point< ValueType >::operator/ ( Point< OtherType >  other) const
noexcept

Divides one point by another.

◆ operator/=() [1/2]

template<typename ValueType>
template<typename OtherType >
Point& Point< ValueType >::operator/= ( Point< OtherType >  other)
noexcept

Divides this point's coordinates by another.

◆ operator*() [2/2]

template<typename ValueType>
template<typename FloatType >
JUCE_CONSTEXPR Point Point< ValueType >::operator* ( FloatType  multiplier) const
noexcept

Returns a point whose coordinates are multiplied by a given scalar value.

◆ operator/() [2/2]

template<typename ValueType>
template<typename FloatType >
JUCE_CONSTEXPR Point Point< ValueType >::operator/ ( FloatType  divisor) const
noexcept

Returns a point whose coordinates are divided by a given scalar value.

◆ operator*=() [2/2]

template<typename ValueType>
template<typename FloatType >
Point& Point< ValueType >::operator*= ( FloatType  multiplier)
noexcept

Multiplies the point's coordinates by a scalar value.

◆ operator/=() [2/2]

template<typename ValueType>
template<typename FloatType >
Point& Point< ValueType >::operator/= ( FloatType  divisor)
noexcept

Divides the point's coordinates by a scalar value.

◆ operator-() [2/2]

template<typename ValueType>
JUCE_CONSTEXPR Point Point< ValueType >::operator- ( ) const
noexcept

Returns the inverse of this point.

◆ getDistanceFromOrigin()

template<typename ValueType>
ValueType Point< ValueType >::getDistanceFromOrigin ( ) const
noexcept

Returns the straight-line distance between this point and the origin.

◆ getDistanceFrom()

template<typename ValueType>
ValueType Point< ValueType >::getDistanceFrom ( Point< ValueType >  other) const
noexcept

Returns the straight-line distance between this point and another one.

◆ getDistanceSquaredFromOrigin()

template<typename ValueType>
JUCE_CONSTEXPR ValueType Point< ValueType >::getDistanceSquaredFromOrigin ( ) const
noexcept

Returns the square of the straight-line distance between this point and the origin.

◆ getDistanceSquaredFrom()

template<typename ValueType>
JUCE_CONSTEXPR ValueType Point< ValueType >::getDistanceSquaredFrom ( Point< ValueType >  other) const
noexcept

Returns the square of the straight-line distance between this point and another one.

◆ getAngleToPoint()

template<typename ValueType>
FloatType Point< ValueType >::getAngleToPoint ( Point< ValueType >  other) const
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

◆ rotatedAboutOrigin()

template<typename ValueType>
Point Point< ValueType >::rotatedAboutOrigin ( ValueType  angleRadians) const
noexcept

Returns the point that would be reached by rotating this point clockwise about the origin by the specified angle.

◆ getPointOnCircumference() [1/2]

template<typename ValueType>
Point<FloatType> Point< ValueType >::getPointOnCircumference ( float  radius,
float  angle 
) const
noexcept

Taking this point to be the centre of a circle, this returns a point on its circumference.

Parameters
radiusthe radius of the circle.
anglethe angle of the point, in radians clockwise from the 12 o'clock position.

◆ getPointOnCircumference() [2/2]

template<typename ValueType>
Point<FloatType> Point< ValueType >::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.

Parameters
radiusXthe horizontal radius of the circle.
radiusYthe vertical radius of the circle.
anglethe angle of the point, in radians clockwise from the 12 o'clock position.

◆ getDotProduct()

template<typename ValueType>
JUCE_CONSTEXPR FloatType Point< ValueType >::getDotProduct ( Point< ValueType >  other) const
noexcept

Returns the dot-product of two points (x1 * x2 + y1 * y2).

◆ applyTransform()

template<typename ValueType>
void Point< ValueType >::applyTransform ( const AffineTransform transform)
noexcept

Uses a transform to change the point's coordinates.

This will only compile if ValueType = float!

See also
AffineTransform::transformPoint

◆ transformedBy()

template<typename ValueType>
Point Point< ValueType >::transformedBy ( const AffineTransform transform) const
noexcept

Returns the position of this point, if it is transformed by a given AffineTransform.

◆ toInt()

template<typename ValueType>
JUCE_CONSTEXPR Point<int> Point< ValueType >::toInt ( ) const
noexcept

Casts this point to a Point<int> object.

◆ toFloat()

template<typename ValueType>
JUCE_CONSTEXPR Point<float> Point< ValueType >::toFloat ( ) const
noexcept

Casts this point to a Point<float> object.

◆ toDouble()

template<typename ValueType>
JUCE_CONSTEXPR Point<double> Point< ValueType >::toDouble ( ) const
noexcept

Casts this point to a Point<double> object.

◆ roundToInt()

template<typename ValueType>
JUCE_CONSTEXPR Point<int> Point< ValueType >::roundToInt ( ) const
noexcept

Casts this point to a Point<int> object using roundToInt() to convert the values.

◆ toString()

template<typename ValueType>
String Point< ValueType >::toString ( ) const

Returns the point as a string in the form "x, y".

Member Data Documentation

◆ x

◆ y


The documentation for this class was generated from the following file: