Package nl.colorize.multimedialib.math
Record Class Point2D
java.lang.Object
java.lang.Record
nl.colorize.multimedialib.math.Point2D
Immutable point within a two-dimensional space, with its X and Y coordinates
defined with float precision. Negative coordinates are permitted.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the angle in degrees from this point towards the specified other point.floatdistanceTo(Point2D other) Returns the distance between this point and the specified other point.final booleanIndicates 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 inthashCode()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.booleanisOrigin()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.multiply(float factor) Returns a new point by multiplying this point's X and Y values with the specified factor.negate()Returns a new point that has X and Y values that are the inverse of this point's X and Y values.toString()Returns a string representation of this record class.floatx()Returns the value of thexrecord component.floaty()Returns the value of theyrecord component.
-
Field Details
-
ORIGIN
-
EPSILON
public static final float EPSILON- See Also:
-
-
Constructor Details
-
Point2D
public Point2D(float x, float y) Creates an instance of aPoint2Drecord class.- Parameters:
x- the value for thexrecord componenty- the value for theyrecord 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. -
multiply
Returns a new point by multiplying this point's X and Y values with the specified factor. -
negate
Returns a new point that has X and Y values that are the inverse of this point's X and Y values. Negating the result will result in the original point, i.e.point.negate().negate().equals(point). -
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 thexrecord component.- Returns:
- the value of the
xrecord component
-
y
public float y()Returns the value of theyrecord component.- Returns:
- the value of the
yrecord component
-