JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | List of all members
juce::Point< ValueType > Class Template Reference

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.
 
Pointoperator= (const Point &)=default
 Copies this point from another one.
 
constexpr bool operator== (Point other) const noexcept
 
constexpr bool operator!= (Point other) const noexcept
 
constexpr bool isOrigin () const noexcept
 Returns true if the point is (0, 0).
 
constexpr bool isFinite () const noexcept
 Returns true if the coordinates are finite values.
 
constexpr ValueType getX () const noexcept
 Returns the point's x coordinate.
 
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.
 
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.
 
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.
 
constexpr Point translated (ValueType deltaX, ValueType deltaY) const noexcept
 Returns a point with a given offset from this one.
 
constexpr Point operator+ (Point other) const noexcept
 Adds two points together.
 
Pointoperator+= (Point other) noexcept
 Adds another point's coordinates to this one.
 
constexpr Point operator- (Point other) const noexcept
 Subtracts one points from another.
 
Pointoperator-= (Point other) noexcept
 Subtracts another point's coordinates to this one.
 
template<typename OtherType >
constexpr Point operator* (Point< OtherType > other) const noexcept
 Multiplies two points together.
 
template<typename OtherType >
Pointoperator*= (Point< OtherType > other) noexcept
 Multiplies another point's coordinates to this one.
 
template<typename OtherType >
constexpr Point operator/ (Point< OtherType > other) const noexcept
 Divides one point by another.
 
template<typename OtherType >
Pointoperator/= (Point< OtherType > other) noexcept
 Divides this point's coordinates by another.
 
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/ (OtherType divisor) const noexcept
 Returns a point whose coordinates are divided by a given scalar value.
 
template<typename FloatType >
Pointoperator*= (FloatType multiplier) noexcept
 Multiplies the point's coordinates by a scalar value.
 
template<typename FloatType >
Pointoperator/= (FloatType divisor) noexcept
 Divides the point's coordinates by a scalar value.
 
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.
 
constexpr ValueType getDistanceSquaredFromOrigin () const noexcept
 Returns the square of 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.
 
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< FloatTypegetPointOnCircumference (float radius, float angle) const noexcept
 Taking this point to be the centre of a circle, this returns a point on its circumference.
 
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.
 
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.
 
constexpr Point< inttoInt () const noexcept
 Casts this point to a Point<int> object.
 
constexpr Point< floattoFloat () const noexcept
 Casts this point to a Point<float> object.
 
constexpr Point< doubletoDouble () const noexcept
 Casts this point to a Point<double> object.
 
constexpr Point< introundToInt () 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.
 

Detailed Description

template<typename ValueType>
class juce::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

@tags{Graphics}

Definition at line 41 of file juce_Point.h.

Member Typedef Documentation

◆ FloatType

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

Definition at line 158 of file juce_Point.h.

Constructor & Destructor Documentation

◆ Point()

template<typename ValueType >
constexpr juce::Point< ValueType >::Point ( ValueType  initialX,
ValueType  initialY 
)
constexprnoexcept

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

Definition at line 51 of file juce_Point.h.

Member Function Documentation

◆ addXY()

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

Adds a pair of coordinates to this value.

Definition at line 93 of file juce_Point.h.

◆ applyTransform()

template<typename ValueType >
void juce::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

Definition at line 225 of file juce_Point.h.

◆ getAngleToPoint()

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

Definition at line 180 of file juce_Point.h.

◆ getDistanceFrom()

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

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

Definition at line 165 of file juce_Point.h.

◆ getDistanceFromOrigin()

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

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

Definition at line 162 of file juce_Point.h.

◆ getDistanceSquaredFrom()

template<typename ValueType >
constexpr ValueType juce::Point< ValueType >::getDistanceSquaredFrom ( Point< ValueType >  other) const
constexprnoexcept

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

Definition at line 171 of file juce_Point.h.

◆ getDistanceSquaredFromOrigin()

template<typename ValueType >
constexpr ValueType juce::Point< ValueType >::getDistanceSquaredFromOrigin ( ) const
constexprnoexcept

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

Definition at line 168 of file juce_Point.h.

◆ getDotProduct()

template<typename ValueType >
constexpr FloatType juce::Point< ValueType >::getDotProduct ( Point< ValueType >  other) const
constexprnoexcept

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

Definition at line 217 of file juce_Point.h.

◆ getPointOnCircumference() [1/2]

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

Definition at line 199 of file juce_Point.h.

◆ getPointOnCircumference() [2/2]

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

Definition at line 210 of file juce_Point.h.

◆ getX()

template<typename ValueType >
constexpr ValueType juce::Point< ValueType >::getX ( ) const
constexprnoexcept

Returns the point's x coordinate.

Definition at line 72 of file juce_Point.h.

◆ getY()

template<typename ValueType >
constexpr ValueType juce::Point< ValueType >::getY ( ) const
constexprnoexcept

Returns the point's y coordinate.

Definition at line 75 of file juce_Point.h.

◆ isFinite()

template<typename ValueType >
constexpr bool juce::Point< ValueType >::isFinite ( ) const
constexprnoexcept

Returns true if the coordinates are finite values.

Definition at line 69 of file juce_Point.h.

◆ isOrigin()

template<typename ValueType >
constexpr bool juce::Point< ValueType >::isOrigin ( ) const
constexprnoexcept

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

Definition at line 66 of file juce_Point.h.

◆ operator!=()

template<typename ValueType >
constexpr bool juce::Point< ValueType >::operator!= ( Point< ValueType >  other) const
constexprnoexcept

Definition at line 63 of file juce_Point.h.

◆ operator*() [1/2]

template<typename ValueType >
template<typename OtherType >
constexpr Point juce::Point< ValueType >::operator* ( OtherType  multiplier) const
constexprnoexcept

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

Definition at line 129 of file juce_Point.h.

◆ operator*() [2/2]

template<typename ValueType >
template<typename OtherType >
constexpr Point juce::Point< ValueType >::operator* ( Point< OtherType other) const
constexprnoexcept

Multiplies two points together.

Definition at line 113 of file juce_Point.h.

◆ operator*=() [1/2]

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

Multiplies the point's coordinates by a scalar value.

Definition at line 147 of file juce_Point.h.

◆ operator*=() [2/2]

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

Multiplies another point's coordinates to this one.

Definition at line 117 of file juce_Point.h.

◆ operator+()

template<typename ValueType >
constexpr Point juce::Point< ValueType >::operator+ ( Point< ValueType >  other) const
constexprnoexcept

Adds two points together.

Definition at line 100 of file juce_Point.h.

◆ operator+=()

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

Adds another point's coordinates to this one.

Definition at line 103 of file juce_Point.h.

◆ operator-() [1/2]

template<typename ValueType >
constexpr Point juce::Point< ValueType >::operator- ( ) const
constexprnoexcept

Returns the inverse of this point.

Definition at line 154 of file juce_Point.h.

◆ operator-() [2/2]

template<typename ValueType >
constexpr Point juce::Point< ValueType >::operator- ( Point< ValueType >  other) const
constexprnoexcept

Subtracts one points from another.

Definition at line 106 of file juce_Point.h.

◆ operator-=()

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

Subtracts another point's coordinates to this one.

Definition at line 109 of file juce_Point.h.

◆ operator/() [1/2]

template<typename ValueType >
template<typename OtherType >
constexpr Point juce::Point< ValueType >::operator/ ( OtherType  divisor) const
constexprnoexcept

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

Definition at line 138 of file juce_Point.h.

◆ operator/() [2/2]

template<typename ValueType >
template<typename OtherType >
constexpr Point juce::Point< ValueType >::operator/ ( Point< OtherType other) const
constexprnoexcept

Divides one point by another.

Definition at line 121 of file juce_Point.h.

◆ operator/=() [1/2]

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

Divides the point's coordinates by a scalar value.

Definition at line 151 of file juce_Point.h.

◆ operator/=() [2/2]

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

Divides this point's coordinates by another.

Definition at line 125 of file juce_Point.h.

◆ operator==()

template<typename ValueType >
constexpr bool juce::Point< ValueType >::operator== ( Point< ValueType >  other) const
constexprnoexcept

Definition at line 57 of file juce_Point.h.

◆ rotatedAboutOrigin()

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

Definition at line 189 of file juce_Point.h.

◆ roundToInt()

template<typename ValueType >
constexpr Point< int > juce::Point< ValueType >::roundToInt ( ) const
constexprnoexcept

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

Definition at line 245 of file juce_Point.h.

◆ setX()

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

Sets the point's x coordinate.

Definition at line 78 of file juce_Point.h.

◆ setXY()

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

Changes the point's x and y coordinates.

Definition at line 90 of file juce_Point.h.

◆ setY()

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

Sets the point's y coordinate.

Definition at line 81 of file juce_Point.h.

◆ toDouble()

template<typename ValueType >
constexpr Point< double > juce::Point< ValueType >::toDouble ( ) const
constexprnoexcept

Casts this point to a Point<double> object.

Definition at line 242 of file juce_Point.h.

◆ toFloat()

template<typename ValueType >
constexpr Point< float > juce::Point< ValueType >::toFloat ( ) const
constexprnoexcept

Casts this point to a Point<float> object.

Definition at line 239 of file juce_Point.h.

◆ toInt()

template<typename ValueType >
constexpr Point< int > juce::Point< ValueType >::toInt ( ) const
constexprnoexcept

Casts this point to a Point<int> object.

Definition at line 236 of file juce_Point.h.

◆ toString()

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

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

Definition at line 248 of file juce_Point.h.

◆ transformedBy()

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

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

Definition at line 228 of file juce_Point.h.

◆ translated()

template<typename ValueType >
constexpr Point juce::Point< ValueType >::translated ( ValueType  deltaX,
ValueType  deltaY 
) const
constexprnoexcept

Returns a point with a given offset from this one.

Definition at line 97 of file juce_Point.h.

◆ withX()

template<typename ValueType >
constexpr Point juce::Point< ValueType >::withX ( ValueType  newX) const
constexprnoexcept

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

Definition at line 84 of file juce_Point.h.

◆ withY()

template<typename ValueType >
constexpr Point juce::Point< ValueType >::withY ( ValueType  newY) const
constexprnoexcept

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

Definition at line 87 of file juce_Point.h.

Member Data Documentation

◆ x

template<typename ValueType >
ValueType juce::Point< ValueType >::x

The point's X coordinate.

Definition at line 251 of file juce_Point.h.

◆ y

template<typename ValueType >
ValueType juce::Point< ValueType >::y

The point's Y coordinate.

Definition at line 252 of file juce_Point.h.


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