Record Class Vector2Di
java.lang.Object
java.lang.Record
nl.pim16aap2.animatedarchitecture.core.util.vector.Vector2Di
Represents an integer x/y pair.
This class is thread-safe, as all modifications return a new instance.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(int val) Adds a value to both the x and the y values of the currentVector2Di.add(int x, int y) Adds values to the current values.Adds anotherVector2Dito the current values.divide(double val) Divides both the x and the y values of the currentVector2Diwith a provided value.divide(double x, double y) Divides the current values with values.divide(int val) Divides both the x and the y values of the currentVector2Diwith a provided value.divide(int x, int 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.leftShift(int bits) Signed bitwise left shift the values in this vector.multiply(double val) Multiplies a value with both the x and the y values of the currentVector2Di.multiply(double x, double y) Multiplies values with the current values.multiply(int val) Multiplies a value with both the x and the y values of the currentVector2Di.multiply(int x, int y) Multiplies values with the current values.Normalizes thisVector2Di.rightShift(int bits) Signed bitwise right shift the values in this vector.subtract(int val) Subtracts a value from both the x and the y values of the currentVector2Di.subtract(int x, int y) Subtracts values from the current values.toDouble()Creates a new double-based 2d vector from this integer-based 2d vector.final StringtoString()Returns a string representation of this record class.intx()Returns the value of thexrecord component.inty()Returns the value of theyrecord component.
-
Constructor Details
-
Vector2Di
public Vector2Di(int x, int y) Creates an instance of aVector2Direcord class.- Parameters:
x- the value for thexrecord componenty- the value for theyrecord component
-
-
Method Details
-
toDouble
Creates a new double-based 2d vector from this integer-based 2d vector.- Returns:
- A new integer-based vector.
-
add
-
add
-
add
-
subtract
-
subtract
-
subtract
-
multiply
-
multiply
-
multiply
-
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
Vector2Diwith the multiplied values.
-
multiply
-
multiply
-
divide
-
divide
-
divide
-
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
Vector2Diwith the divided values.
-
divide
-
divide
-
leftShift
-
rightShift
-
normalized
-
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 int x()Returns the value of thexrecord component.- Returns:
- the value of the
xrecord component
-
y
public int y()Returns the value of theyrecord component.- Returns:
- the value of the
yrecord component
-