Record Class Vector3Di

java.lang.Object
java.lang.Record
nl.pim16aap2.animatedarchitecture.core.util.vector.Vector3Di
All Implemented Interfaces:
IVector3D

public record Vector3Di(int x, int y, int z) extends Record implements IVector3D
Represents an integer x/y/z set.

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

  • Constructor Details

    • Vector3Di

      public Vector3Di(IVector3D other)
    • Vector3Di

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

    • of

      public static Vector3Di of(IVector3D other)
      Creates a Vector3Di from a IVector3D.

      If the provided IVector3D is already a Vector3Di, the same instance is returned, otherwise a new instance is created by rounding the x/y/z values to the nearest integer.

      Parameters:
      other - A Vector3Di to retrieve as Vector3Di
      Returns:
      A Vector3Di representing the provided Vector3Di. If the provided Vector3Di was already of this type, the same instance is returned.
    • toInteger

      @CheckReturnValue @Contract(pure=true) public Vector3Di toInteger()
      Description copied from interface: IVector3D
      Creates a new integer-based 3d vector from this 3d vector.

      The values of a double-based vector will be rounded to obtain the integer values.

      Specified by:
      toInteger in interface IVector3D
      Returns:
      A new integer-based vector.
    • toDouble

      @CheckReturnValue @Contract(pure=true) public Vector3Dd toDouble()
      Description copied from interface: IVector3D
      Creates a new double-based 3d vector from this integer-based 3d vector.
      Specified by:
      toDouble in interface IVector3D
      Returns:
      A new double-based vector.
    • add

      @CheckReturnValue @Contract(pure=true) public Vector3Di add(int x, int y, int z)
      Adds integer 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.
      z - The z value to add to the current z value.
      Returns:
      A new Vector3Di with the added values.
    • add

      @CheckReturnValue @Contract(pure=true) public Vector3Dd add(double x, double y, double z)
      Adds floating point values to the current x/y/z.
      Parameters:
      x - The x value to add to the current x value.
      y - The y value to add to the current y value.
      z - The z value to add to the current z value.
      Returns:
      A new Vector3Dd with the added values.
    • add

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

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

      @CheckReturnValue @Contract(pure=true) public Vector3Di add(int val)
      Adds an integer value to the x, y, and z values of the current Vector3Di.
      Parameters:
      val - The integer value to add to the x, y, and z values.
      Returns:
      A new Vector3Di with the value added to the values.
    • add

      @CheckReturnValue @Contract(pure=true) public Vector3Dd add(double val)
      Adds a floating point value to the x, y, and z values of the current Vector3Di.
      Parameters:
      val - The floating point value to add to the x, y, and z values.
      Returns:
      A new Vector3Dd with the value added to the values.
    • subtract

      @CheckReturnValue @Contract(pure=true) public Vector3Di subtract(int x, int y, int z)
      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.
      z - The z value to subtract from the current z value.
      Returns:
      A new Vector3Di with the subtracted values.
    • subtract

      @CheckReturnValue @Contract(pure=true) public Vector3Dd subtract(double x, double y, double z)
      Subtracts floating point 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.
      z - The z value to subtract from the current z value.
      Returns:
      A new Vector3Dd with the subtracted values.
    • subtract

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

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

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

      @CheckReturnValue @Contract(pure=true) public Vector3Dd subtract(double val)
      Subtracts a floating point value from the x, y, and z values of the current Vector3Di.
      Parameters:
      val - The floating point value to subtract from the x, y, and z values.
      Returns:
      A new Vector3Dd with the value subtracted from the values.
    • multiply

      @CheckReturnValue @Contract(pure=true) public Vector3Di multiply(int x, int y, int z)
      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.
      z - The z value to multiply with the current z value.
      Returns:
      A new Vector3Di with the multiplied values.
    • multiply

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

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

      @CheckReturnValue @Contract(pure=true) public Vector3Dd multiply(double x, double y, double z)
      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.
      z - The z value to multiply with the current z value.
      Returns:
      A new Vector3Dd with the multiplied values.
    • multiply

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

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

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

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

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

      @CheckReturnValue @Contract(pure=true) public Vector3Di divide(double x, double y, double z)
      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.
      z - The z value to use as divisor for the current z value.
      Returns:
      A new Vector3Di with the divided values.
    • divide

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

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

      @CheckReturnValue @Contract(pure=true) public Vector3Di normalized()
      Normalizes this Vector3Di.
      Returns:
      A new, normalized, Vector3Di.
    • rotateAroundXAxis

      @CheckReturnValue @Contract(pure=true) public Vector3Di rotateAroundXAxis(IVector3D pivotPoint, double radians)
      Rotates this point around another point along the x axis.
      Parameters:
      pivotPoint - The point around which to rotate this point.
      radians - How far to rotate this point (in radians).
      Returns:
      A new Vector3Di rotated around the pivot point.
    • rotateAroundYAxis

      @CheckReturnValue @Contract(pure=true) public Vector3Di rotateAroundYAxis(IVector3D pivotPoint, double radians)
      Rotates this point around another point along the y axis.
      Parameters:
      pivotPoint - The point around which to rotate this point.
      radians - How far to rotate this point (in radians).
      Returns:
      A new Vector3Di rotated around the pivot point.
    • rotateAroundZAxis

      @CheckReturnValue @Contract(pure=true) public Vector3Di rotateAroundZAxis(IVector3D pivotPoint, double radians)
      Rotates this point around another point along the z axis.
      Parameters:
      pivotPoint - The point around which to rotate this point.
      radians - How far to rotate this point (in radians).
      Returns:
      A new Vector3Di rotated around the pivot point.
    • leftShift

      @CheckReturnValue @Contract(pure=true) public Vector3Di 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 Vector3Di.
    • rightShift

      @CheckReturnValue @Contract(pure=true) public Vector3Di 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 Vector3Di.
    • absolute

      @CheckReturnValue @Contract(pure=true) public Vector3Di absolute()
      Gets the absolute values of this vector.
      Returns:
      A new Vector3Di.
    • max

      @CheckReturnValue @Contract(pure=true) public int max()
      Returns the highest value in this vector.
      Returns:
      The highest value in this vector.
    • min

      @CheckReturnValue @Contract(pure=true) public int min()
      Returns the lowest value in this vector.
      Returns:
      The lowest value in this vector.
    • sum

      public int sum()
      Returns the sum of the x, y, and z values.
      Returns:
      The sum of the x, y, and z values.
    • xD

      public double xD()
      Description copied from interface: IVector3D
      Returns the x value as double.
      Specified by:
      xD in interface IVector3D
      Returns:
      The x value as double.
    • yD

      public double yD()
      Description copied from interface: IVector3D
      Returns the y value as double.
      Specified by:
      yD in interface IVector3D
      Returns:
      The y value as double.
    • zD

      public double zD()
      Description copied from interface: IVector3D
      Returns the z value as double.
      Specified by:
      zD in interface IVector3D
      Returns:
      The z value as double.
    • floor

      public Vector3Di floor()
      Description copied from interface: IVector3D
      Returns a new vector with Math.floor(double) applied to the current values.
      Specified by:
      floor in interface IVector3D
      Returns:
      A new vector with Math.floor(double) applied to the current values.
    • round

      public Vector3Di round()
      Description copied from interface: IVector3D
      Returns a new vector with Math.round(double) applied to the current values.
      Specified by:
      round in interface IVector3D
      Returns:
      A new vector with Math.round(double) applied to the current values.
    • ceil

      public Vector3Di ceil()
      Description copied from interface: IVector3D
      Returns a new vector with Math.ceil(double) applied to the current values.
      Specified by:
      ceil in interface IVector3D
      Returns:
      A new vector with Math.ceil(double) applied to the current values.
    • 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
    • z

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