Record Class Vector2Dd
java.lang.Object
java.lang.Record
nl.pim16aap2.animatedarchitecture.core.util.vector.Vector2Dd
Represents a double x/y pair.
This class is thread-safe, as all modifications return a new instance.
-
Constructor Summary
ConstructorsConstructorDescriptionVector2Dd(double x, double y) Creates an instance of aVector2Ddrecord class. -
Method Summary
Modifier and TypeMethodDescriptionadd(double val) Adds a value to both the x and the y values of the currentVector2Dd.add(double x, double y) Adds values to the current values.Adds anotherVector2Ddto the current values.Adds anotherVector2Dito the current values.divide(double val) Divides both the x and the y values of the currentVector2Ddwith a provided value.divide(double x, double y) Divides the current values with values.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.multiply(double val) Multiplies a value with both the x and the y values of the currentVector2Dd.multiply(double x, double y) Multiplies values with the current values.Normalizes thisVector2Dd.subtract(double val) Subtracts a value from both the x and the y values of the currentVector2Dd.subtract(double x, double y) Subtracts values from the current values.Creates a new integer-based 2d vector from this double-based 2d vector.final StringtoString()Returns a string representation of this record class.toString(int decimals) Returns a String representation of this 2d vector.doublex()Returns the value of thexrecord component.doubley()Returns the value of theyrecord component.
-
Constructor Details
-
Vector2Dd
public Vector2Dd(double x, double y) Creates an instance of aVector2Ddrecord class.- Parameters:
x- the value for thexrecord componenty- the value for theyrecord component
-
-
Method Details
-
toInteger
Creates a new integer-based 2d vector from this double-based 2d vector.The values of the double-based vector will be rounded to obtain the integer values.
- Returns:
- A new integer-based vector.
-
add
-
add
-
add
-
add
-
subtract
-
subtract
-
subtract
-
subtract
-
multiply
Multiplies values with the current values.- Parameters:
x- The x value to multiply with the current x value.y- The y value to multiply with the current y value.- Returns:
- A new
Vector2Ddwith the multiplied values.
-
multiply
-
multiply
-
multiply
-
divide
Divides the current values with values.- Parameters:
x- The x value to use as divisor for the current x value.y- The y value to use as divisor for the current y value.- Returns:
- A new
Vector2Ddwith the divided values.
-
divide
-
divide
-
divide
-
normalized
-
toString
Returns a String representation of this 2d vector. The output will be the same astoString()with the only difference being that the x/y coordinate values will be formatted to a specific number of decimal places.- Parameters:
decimals- The number of decimals to print for each value.- Returns:
- A String representation of this vector.
-
toString
-
hashCode
-
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 thecomparemethod from their corresponding wrapper classes. -
x
public double x()Returns the value of thexrecord component.- Returns:
- the value of the
xrecord component
-
y
public double y()Returns the value of theyrecord component.- Returns:
- the value of the
yrecord component
-