Package nl.colorize.multimedialib.math
Record Class Point2D
java.lang.Object
java.lang.Record
nl.colorize.multimedialib.math.Point2D
Describes a point with X and Y coordinates within a two-dimensional space.
Point coordinates have float precision, and point instances are immutable.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfloat
Returns the angle in degrees from this point towards the specified other point.float
distanceTo
(Point2D other) Returns the distance between this point and the specified other point.final boolean
Indicates whether some other object is "equal to" this one.findCenter
(Point2D other) Returns a new point that is positioned in the center between this point and the specified other point.final int
hashCode()
Returns a hash code value for this object.interpolate
(Point2D other, float delta) Returns a new point with a position that uses linear interpolation between this point and the specified other point.interpolate
(Point2D other, float delta, nl.colorize.util.animation.Interpolation method) Returns a new point with a position that is interpolated between this point and the specified other point.boolean
isOrigin()
move
(float deltaX, float deltaY) Returns a new point that starts from this point and then adds the specified offset.Returns a new point that starts from this point and then adds the specified offset.toString()
Returns a string representation of this record class.float
x()
Returns the value of thex
record component.float
y()
Returns the value of they
record component.
-
Field Details
-
ORIGIN
-
-
Constructor Details
-
Point2D
public Point2D(float x, float y) Creates an instance of aPoint2D
record class.- Parameters:
x
- the value for thex
record componenty
- the value for they
record component
-
-
Method Details
-
isOrigin
public boolean isOrigin() -
distanceTo
Returns the distance between this point and the specified other point. -
angleTo
Returns the angle in degrees from this point towards the specified other point. If the points are identical this will return an angle of 0. -
findCenter
Returns a new point that is positioned in the center between this point and the specified other point. -
interpolate
public Point2D interpolate(Point2D other, float delta, nl.colorize.util.animation.Interpolation method) Returns a new point with a position that is interpolated between this point and the specified other point. The delta is represented by a number between 0.0 (position of this point) and 1.0 (position of the other point). -
interpolate
Returns a new point with a position that uses linear interpolation between this point and the specified other point. The delta is represented by a number between 0.0 (position of this point) and 1.0 (position of the other point). -
move
Returns a new point that starts from this point and then adds the specified offset. -
move
Returns a new point that starts from this point and then adds the specified offset. -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='. -
x
public float x()Returns the value of thex
record component.- Returns:
- the value of the
x
record component
-
y
public float y()Returns the value of they
record component.- Returns:
- the value of the
y
record component
-