Record Class Vector2Di

java.lang.Object
java.lang.Record
nl.pim16aap2.animatedarchitecture.core.util.vector.Vector2Di

public record Vector2Di(int x, int y) extends Record
Represents an integer x/y pair.

This class is thread-safe, as all modifications return a new instance.

  • Constructor Details

    • Vector2Di

      public Vector2Di(int x, int y)
      Creates an instance of a Vector2Di record class.
      Parameters:
      x - the value for the x record component
      y - the value for the y record component
  • Method Details

    • toDouble

      @CheckReturnValue @Contract(pure=true) public Vector2Dd toDouble()
      Creates a new double-based 2d vector from this integer-based 2d vector.
      Returns:
      A new integer-based vector.
    • add

      @CheckReturnValue @Contract(pure=true) public Vector2Di add(int x, int y)
      Adds values to the current values.
      Parameters:
      x - The x value to add to the current x value.
      y - The y value to add to the current y value.
      Returns:
      A new Vector2Di with the added values.
    • add

      @CheckReturnValue @Contract(pure=true) public Vector2Di add(Vector2Di other)
      Adds another Vector2Di to the current values.
      Parameters:
      other - The other Vector2Di to add to the current one.
      Returns:
      A new Vector2Di with the added values.
    • add

      @CheckReturnValue @Contract(pure=true) public Vector2Di add(int val)
      Adds a value to both the x and the y values of the current Vector2Di.
      Parameters:
      val - The value to add to both the x and the y values.
      Returns:
      A new Vector2Di with the value added to the values.
    • subtract

      @CheckReturnValue @Contract(pure=true) public Vector2Di subtract(int x, int y)
      Subtracts values from the current values.
      Parameters:
      x - The x value to subtract from the current x value.
      y - The y value to subtract from the current y value.
      Returns:
      A new Vector2Di with the subtracted values.
    • subtract

      @CheckReturnValue @Contract(pure=true) public Vector2Di subtract(Vector2Di other)
      Subtracts another Vector2Di from both the x and the y values of the current Vector2Di.
      Parameters:
      other - The other Vector2Di to subtract from the x and the y values.
      Returns:
      The new Vector2Di with the value subtracted from the values.
    • subtract

      @CheckReturnValue @Contract(pure=true) public Vector2Di subtract(int val)
      Subtracts a value from both the x and the y values of the current Vector2Di.
      Parameters:
      val - The value to subtract from both the x and the y values.
      Returns:
      A new Vector2Di with the value subtracted from the values.
    • multiply

      @CheckReturnValue @Contract(pure=true) public Vector2Di multiply(int x, int y)
      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 Vector2Di with the multiplied values.
    • multiply

      @CheckReturnValue @Contract(pure=true) public Vector2Di multiply(Vector2Di other)
      Multiplies another Vector2Di from with the x and the y values of the current Vector2Di.
      Parameters:
      other - The other Vector2Di to multiply with the x and the y values.
      Returns:
      The new Vector2Di with the value multiplied with the values.
    • multiply

      @CheckReturnValue @Contract(pure=true) public Vector2Di multiply(int val)
      Multiplies a value with both the x and the y values of the current Vector2Di.
      Parameters:
      val - The value to multiply from both the x and the y values.
      Returns:
      A new Vector2Di with the value multiplied with the values.
    • multiply

      @CheckReturnValue @Contract(pure=true) public Vector2Di multiply(double x, double y)
      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 Vector2Di with the multiplied values.
    • multiply

      @CheckReturnValue @Contract(pure=true) public Vector2Di multiply(Vector2Dd other)
      Multiplies another Vector2Dd from with the x and the y values of the current Vector2Di.
      Parameters:
      other - The other Vector2Dd to multiply with the x and the y values.
      Returns:
      The new Vector2Di with the value multiplied with the values.
    • multiply

      @CheckReturnValue @Contract(pure=true) public Vector2Di multiply(double val)
      Multiplies a value with both the x and the y values of the current Vector2Di.
      Parameters:
      val - The value to multiply from both the x and the y values.
      Returns:
      A new Vector2Di with the value multiplied with the values.
    • divide

      @CheckReturnValue @Contract(pure=true) public Vector2Di divide(int x, int y)
      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 Vector2Di with the divided values.
    • divide

      @CheckReturnValue @Contract(pure=true) public Vector2Di divide(Vector2Di other)
      Divides the x and y values of the current Vector2Di with the x and the y values of the provided Vector2Di.
      Parameters:
      other - The other Vector2Di to use as divisor for the current x and the y values.
      Returns:
      A new Vector2Di with the divided values.
    • divide

      @CheckReturnValue @Contract(pure=true) public Vector2Di divide(int val)
      Divides both the x and the y values of the current Vector2Di with a provided value.
      Parameters:
      val - The value to use as divisor for both the x and the y values.
      Returns:
      A new Vector2Di with the divided values.
    • divide

      @CheckReturnValue @Contract(pure=true) public Vector2Di divide(double x, double y)
      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 Vector2Di with the divided values.
    • divide

      @CheckReturnValue @Contract(pure=true) public Vector2Di divide(Vector2Dd other)
      Divides the x and y values of the current Vector2Di with the x and the y values of the provided Vector2Dd.
      Parameters:
      other - The other Vector2Dd to use as divisor for the current x and the y values.
      Returns:
      A new Vector2Di with the divided values.
    • divide

      @CheckReturnValue @Contract(pure=true) public Vector2Di divide(double val)
      Divides both the x and the y values of the current Vector2Di with a provided value.
      Parameters:
      val - The value to use as divisor for both the x and the y values.
      Returns:
      A new Vector2Di with the divided values.
    • leftShift

      @CheckReturnValue @Contract(pure=true) public Vector2Di leftShift(int bits)
      Signed bitwise left shift the values in this vector.
      Parameters:
      bits - The number of bits to shift the values.
      Returns:
      A new Vector2Di.
    • rightShift

      @CheckReturnValue @Contract(pure=true) public Vector2Di rightShift(int bits)
      Signed bitwise right shift the values in this vector.
      Parameters:
      bits - The number of bits to shift the values.
      Returns:
      A new Vector2Di.
    • normalized

      @CheckReturnValue @Contract(pure=true) public Vector2Di normalized()
      Normalizes this Vector2Di.
      Returns:
      A new Vector2Di with normalized
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • x

      public int x()
      Returns the value of the x record component.
      Returns:
      the value of the x record component
    • y

      public int y()
      Returns the value of the y record component.
      Returns:
      the value of the y record component