40template <
typename ValueType>
57 constexpr inline bool operator== (
Point other)
const noexcept
59 const auto tie = [] (
const Point& p) {
return std::tie (p.x, p.y); };
60 return tie (*
this) == tie (
other);
63 constexpr inline bool operator!= (
Point other)
const noexcept {
return ! operator== (
other); }
72 constexpr inline ValueType
getX()
const noexcept {
return x; }
75 constexpr inline ValueType
getY()
const noexcept {
return y; }
97 constexpr Point translated (ValueType deltaX, ValueType deltaY)
const noexcept {
return Point (
x + deltaX,
y + deltaY); }
112 template <
typename OtherType>
116 template <
typename OtherType>
120 template <
typename OtherType>
124 template <
typename OtherType>
128 template <
typename OtherType>
137 template <
typename OtherType>
146 template <
typename FloatType>
150 template <
typename FloatType>
230 return Point (
static_cast<ValueType
> (transform.mat00 * (
float)
x + transform.mat01 * (
float)
y + transform.mat02),
231 static_cast<ValueType
> (transform.mat10 * (
float)
x + transform.mat11 * (
float)
y + transform.mat12));
256template <
typename ValueType>
A pair of (x, y) coordinates.
constexpr FloatType getDotProduct(Point other) const noexcept
Returns the dot-product of two points (x1 * x2 + y1 * y2).
constexpr Point translated(ValueType deltaX, ValueType deltaY) const noexcept
Returns a point with a given offset from this one.
ValueType getDistanceFrom(Point other) const noexcept
Returns the straight-line distance between this point and 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 spec...
FloatType getAngleToPoint(Point other) const noexcept
Returns the angle from this point to another one.
void setY(ValueType newY) noexcept
Sets the point's y coordinate.
constexpr Point< float > toFloat() const noexcept
Casts this point to a Point<float> object.
constexpr Point operator+(Point other) const noexcept
Adds two points together.
constexpr Point operator-() const noexcept
Returns the inverse of this point.
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.
constexpr ValueType getY() const noexcept
Returns the point's y coordinate.
constexpr ValueType getDistanceSquaredFromOrigin() const noexcept
Returns the square of the straight-line distance between this point and the origin.
void setX(ValueType newX) noexcept
Sets the point's x coordinate.
constexpr Point()=default
Creates a point at the origin.
constexpr Point< int > roundToInt() const noexcept
Casts this point to a Point<int> object using roundToInt() to convert the values.
constexpr ValueType getX() const noexcept
Returns the point's x coordinate.
constexpr Point< int > toInt() const noexcept
Casts this point to a Point<int> object.
constexpr Point< double > toDouble() const noexcept
Casts this point to a Point<double> object.
String toString() const
Returns the point as a string in the form "x, y".
void applyTransform(const AffineTransform &transform) noexcept
Uses a transform to change the point's coordinates.
Point & operator+=(Point other) noexcept
Adds another point's coordinates to this one.
Point & operator*=(Point< OtherType > other) noexcept
Multiplies another point's coordinates to this one.
constexpr Point operator/(Point< OtherType > other) const noexcept
Divides one point by another.
constexpr bool isOrigin() const noexcept
Returns true if the point is (0, 0).
ValueType y
The point's Y coordinate.
void addXY(ValueType xToAdd, ValueType yToAdd) noexcept
Adds a pair of coordinates to this value.
Point transformedBy(const AffineTransform &transform) const noexcept
Returns the position of this point, if it is transformed by a given AffineTransform.
constexpr Point(const Point &)=default
Creates a copy of another point.
constexpr bool isFinite() const noexcept
Returns true if the coordinates are finite values.
Point & operator-=(Point other) noexcept
Subtracts another point's coordinates to this one.
constexpr ValueType getDistanceSquaredFrom(Point other) const noexcept
Returns the square of the straight-line distance between this point and another one.
constexpr Point operator*(Point< OtherType > other) const noexcept
Multiplies two points together.
ValueType x
The point's X coordinate.
constexpr Point withX(ValueType newX) const noexcept
Returns a point which has the same Y position as this one, but a new X.
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.
Point & operator=(const Point &)=default
Copies this point from another one.
Point & operator/=(Point< OtherType > other) noexcept
Divides this point's coordinates by another.
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.
ValueType getDistanceFromOrigin() const noexcept
Returns the straight-line distance between this point and the origin.
constexpr Point(ValueType initialX, ValueType initialY) noexcept
Creates a point from an (x, y) position.
const DirectoryEntry & operator*(const DirectoryEntry &e) noexcept
A convenience operator so that the expression *it++ works correctly when it is an instance of RangedD...
Type juce_hypot(Type a, Type b) noexcept
Using juce_hypot is easier than dealing with the different types of hypot function that are provided ...
bool juce_isfinite(NumericType value) noexcept
The isfinite() method seems to vary between platforms, so this is a platform-independent function for...
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
int roundToInt(const FloatType value) noexcept
Fast floating-point-to-integer conversion.