LMMS
Loading...
Searching...
No Matches
juce::Point< ValueType > Class Template Reference

#include <juce_Point.h>

Public Types

using FloatType = typename TypeHelpers::SmallestFloatType<ValueType>::type

Public Member Functions

constexpr Point ()=default
constexpr Point (const Point &)=default
constexpr Point (ValueType initialX, ValueType initialY) noexcept
Pointoperator= (const Point &)=default
constexpr bool operator== (Point other) const noexcept
constexpr bool operator!= (Point other) const noexcept
constexpr bool isOrigin () const noexcept
constexpr bool isFinite () const noexcept
constexpr ValueType getX () const noexcept
constexpr ValueType getY () const noexcept
void setX (ValueType newX) noexcept
void setY (ValueType newY) noexcept
constexpr Point withX (ValueType newX) const noexcept
constexpr Point withY (ValueType newY) const noexcept
void setXY (ValueType newX, ValueType newY) noexcept
void addXY (ValueType xToAdd, ValueType yToAdd) noexcept
constexpr Point translated (ValueType deltaX, ValueType deltaY) const noexcept
constexpr Point operator+ (Point other) const noexcept
Pointoperator+= (Point other) noexcept
constexpr Point operator- (Point other) const noexcept
Pointoperator-= (Point other) noexcept
template<typename OtherType>
constexpr Point operator* (Point< OtherType > other) const noexcept
template<typename OtherType>
Pointoperator*= (Point< OtherType > other) noexcept
template<typename OtherType>
constexpr Point operator/ (Point< OtherType > other) const noexcept
template<typename OtherType>
Pointoperator/= (Point< OtherType > other) noexcept
template<typename OtherType>
constexpr Point operator* (OtherType multiplier) const noexcept
template<typename OtherType>
constexpr Point operator/ (OtherType divisor) const noexcept
template<typename FloatType>
Pointoperator*= (FloatType multiplier) noexcept
template<typename FloatType>
Pointoperator/= (FloatType divisor) noexcept
constexpr Point operator- () const noexcept
ValueType getDistanceFromOrigin () const noexcept
ValueType getDistanceFrom (Point other) const noexcept
constexpr ValueType getDistanceSquaredFromOrigin () const noexcept
constexpr ValueType getDistanceSquaredFrom (Point other) const noexcept
FloatType getAngleToPoint (Point other) const noexcept
Point rotatedAboutOrigin (ValueType angleRadians) const noexcept
Point< FloatTypegetPointOnCircumference (float radius, float angle) const noexcept
Point< FloatTypegetPointOnCircumference (float radiusX, float radiusY, float angle) const noexcept
constexpr FloatType getDotProduct (Point other) const noexcept
void applyTransform (const AffineTransform &transform) noexcept
Point transformedBy (const AffineTransform &transform) const noexcept
constexpr Point< inttoInt () const noexcept
constexpr Point< float > toFloat () const noexcept
constexpr Point< double > toDouble () const noexcept
constexpr Point< introundToInt () const noexcept
String toString () const

Public Attributes

ValueType x {}
ValueType y {}

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}

Member Typedef Documentation

◆ FloatType

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

Constructor & Destructor Documentation

◆ Point() [1/3]

template<typename ValueType>
Point::Point ( )
constexprdefaultnoexcept

Creates a point at the origin

◆ Point() [2/3]

template<typename ValueType>
juce::Point< ValueType >::Point ( const Point< ValueType > & )
constexprdefault

Creates a copy of another point.

◆ Point() [3/3]

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

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

Member Function Documentation

◆ addXY()

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

Adds a pair of coordinates to this value.

◆ applyTransform()

template<typename ValueType>
void juce::Point< ValueType >::applyTransform ( const AffineTransform & transform)
inlinenoexcept

Uses a transform to change the point's coordinates. This will only compile if ValueType = float!

See also
AffineTransform::transformPoint

◆ getAngleToPoint()

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

◆ getDistanceFrom()

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

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

◆ getDistanceFromOrigin()

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

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

◆ getDistanceSquaredFrom()

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

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

◆ getDistanceSquaredFromOrigin()

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

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

◆ getDotProduct()

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

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

◆ getPointOnCircumference() [1/2]

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

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 > juce::Point< ValueType >::getPointOnCircumference ( float radiusX,
float radiusY,
float angle ) const
inlinenoexcept

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.

◆ getX()

template<typename ValueType>
const T & Point::getX ( ) const
inlineconstexprnoexcept

Returns the point's x coordinate.

◆ getY()

template<typename ValueType>
const T & Point::getY ( ) const
inlineconstexprnoexcept

Returns the point's y coordinate.

◆ isFinite()

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

Returns true if the coordinates are finite values.

◆ isOrigin()

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

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

◆ operator!=()

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

◆ operator*() [1/2]

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

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

◆ operator*() [2/2]

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

Multiplies two points together

◆ operator*=() [1/2]

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

Multiplies the point's coordinates by a scalar value.

◆ operator*=() [2/2]

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

Multiplies another point's coordinates to this one

◆ operator+()

template<typename ValueType>
Point< T > Point::operator+ ( Point< ValueType > other) const
inlineconstexprnoexcept

Adds two points together

◆ operator+=()

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

Adds another point's coordinates to this one

◆ operator-() [1/2]

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

Returns the inverse of this point.

◆ operator-() [2/2]

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

Subtracts one points from another

◆ operator-=()

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

Subtracts another point's coordinates to this one

◆ operator/() [1/2]

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

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

◆ operator/() [2/2]

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

Divides one point by another

◆ operator/=() [1/2]

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

Divides the point's coordinates by a scalar value.

◆ operator/=() [2/2]

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

Divides this point's coordinates by another

◆ operator=()

template<typename ValueType>
Point< T > & Point::operator= ( const Point< ValueType > & )
defaultnoexcept

Copies this point from another one.

◆ operator==()

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

◆ rotatedAboutOrigin()

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

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

◆ roundToInt()

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

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

◆ setX()

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

Sets the point's x coordinate.

◆ setXY()

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

Changes the point's x and y coordinates.

◆ setY()

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

Sets the point's y coordinate.

◆ toDouble()

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

Casts this point to a Point<double> object.

◆ toFloat()

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

Casts this point to a Point<float> object.

◆ toInt()

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

Casts this point to a Point<int> object.

◆ toString()

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

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

◆ transformedBy()

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

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

◆ translated()

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

Returns a point with a given offset from this one.

◆ withX()

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

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

◆ withY()

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

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

Member Data Documentation

◆ x

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

The point's X coordinate.

◆ y

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

The point's Y coordinate.


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