Klasse Vector3i

java.lang.Object
net.risingworld.api.utils.Vector3i
Alle implementierten Schnittstellen:
Serializable

public class Vector3i extends Object implements Serializable
A Vector which holds three int values: X, Y and Z
It can be used to represent a three dimensional value, like an integer position (e.g a block position or a chunk offset).
Siehe auch:
  • Feldübersicht

    Felder
    Modifizierer und Typ
    Feld
    Beschreibung
    static final Vector3i
    A vector with values 1, 1, 1
    int
    The integer X value of this vector
    int
    The integer Y value of this vector
    int
    The integer Z value of this vector
    static final Vector3i
    A vector with values 0, 0, 0
  • Konstruktorübersicht

    Konstruktoren
    Konstruktor
    Beschreibung
    Creates a new Vector3i with default values 0, 0, 0.
    Vector3i(int x, int y, int z)
    Creates a new Vector3i with the provided int values.
    Creates a new Vector3i and copies the X, Y and Z values from the provided vector.
  • Methodenübersicht

    Modifizierer und Typ
    Methode
    Beschreibung
    addLocal(int addX, int addY, int addZ)
    Adds the provided values to the values of this vector.
    Adds the values of the provided vector to the values of this vector.
    float
    Gets the angle between this vector and another vector.
    Please note: Both vectors need to be unit vectors (normalized).
    Creates a copy of this Vector.
    crossLocal(int v2x, int v2y, int v2z)
    Calculates the cross product of this vector and the provided coordinates.
    Calculates the cross product of this vector and another vector.
    float
    distance(int x, int y, int z)
    Gets the distance between this vector and the provided coordinates.
    float
    Gets the distance between this vector and another vector.
    float
    distanceSquared(int x, int y, int z)
    Gets the squared distance between this vector and the provided coordinates.
    float
    Gets the squared distance between this vector and another Vector3i.
    divideLocal(int scalar)
     
     
    float
    dot(int x, int y, int z)
    Gets the dot product of this vector with the provided coordinates.
    float
    dot(Vector3i other)
    Gets the dot product of this vector with the provided vector.
    boolean
    equals(int x, int y, int z)
     
    boolean
    Gets whether or not this vector is equal to another object.
    int
    Returns the x value of this vector.
    int
    Returns the y value of this vector.
    int
    Returns the z value of this vector.
    int
    Gets a unique* hash code for this vector, based on its values.
    boolean
    isOrthogonal(int x, int y, int z)
    Checks if this vector is orthogonal to another vector (i.e the angle between both vectors is ~ 90° degree).
    boolean
    Checks if this vector is orthogonal to another vector (i.e the angle between both vectors is ~ 90° degree).
    boolean
    Checks if this vector is a unit vector.
    float
    Gets the length of this vector.
    float
    Gets the squared length of this vector.
    multLocal(int scalar)
    Multiplies the values of this vector with the provided scalar.
    multLocal(int multX, int multY, int multZ)
    Multiplies the values of this vector with the provided values.
    Multiplies the values of this vector with the values of the provided vector.
    Negates all values of this vector.
    Normalizes this vector (i.e turn it into a unit vector).
    set(int x, int y, int z)
    Sets the x, y and z values of this vector to the provided int values.
    set(Vector3i vector)
    Sets the x, y and z values of this vector to the values of the provided vector.
    setX(int x)
    Sets the x value of this vector.
    setY(int y)
    Sets the y value of this vector.
    setZ(int z)
    Sets the z value of this vector.
    subtractLocal(int subtractX, int subtractY, int subtractZ)
    Subtracts the provided values from the values of this vector.
    Subtracts the values of the provided vector from the values of this vector.
    Gets a String representation of this vector, for example (23, -5)
    Sets all values to 0 (same set set(0, 0, 0);).

    Von Klasse geerbte Methoden java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Felddetails

    • ZERO

      public static final Vector3i ZERO
      A vector with values 0, 0, 0
    • ONE

      public static final Vector3i ONE
      A vector with values 1, 1, 1
    • x

      public int x
      The integer X value of this vector
    • y

      public int y
      The integer Y value of this vector
    • z

      public int z
      The integer Z value of this vector
  • Konstruktordetails

    • Vector3i

      public Vector3i()
      Creates a new Vector3i with default values 0, 0, 0.
    • Vector3i

      public Vector3i(int x, int y, int z)
      Creates a new Vector3i with the provided int values.
      Parameter:
      x - the x value of the vector.
      y - the y value of the vector.
      z - the z value of the vector.
    • Vector3i

      public Vector3i(Vector3i copy)
      Creates a new Vector3i and copies the X, Y and Z values from the provided vector.
      Parameter:
      copy - the Vector3i to copy.
  • Methodendetails

    • copy

      public Vector3i copy()
      Creates a copy of this Vector.
      Gibt zurück:
      a new instance with the same values of this Vector.
    • set

      public Vector3i set(Vector3i vector)
      Sets the x, y and z values of this vector to the values of the provided vector.
      Parameter:
      vector - the Vector3i to copy.
      Gibt zurück:
      this vector.
    • set

      public Vector3i set(int x, int y, int z)
      Sets the x, y and z values of this vector to the provided int values.
      Parameter:
      x - the x value.
      y - the y value.
      z - the z value.
      Gibt zurück:
      this vector.
    • setX

      public Vector3i setX(int x)
      Sets the x value of this vector.
      Parameter:
      x - the new x value.
      Gibt zurück:
      this vector.
    • setY

      public Vector3i setY(int y)
      Sets the y value of this vector.
      Parameter:
      y - the new y value.
      Gibt zurück:
      this vector.
    • setZ

      public Vector3i setZ(int z)
      Sets the z value of this vector.
      Parameter:
      z - the new z value.
      Gibt zurück:
      this vector.
    • getX

      public int getX()
      Returns the x value of this vector.
      Gibt zurück:
      the current x value.
    • getY

      public int getY()
      Returns the y value of this vector.
      Gibt zurück:
      the current y value.
    • getZ

      public int getZ()
      Returns the z value of this vector.
      Gibt zurück:
      the current z value.
    • dot

      public float dot(Vector3i other)
      Gets the dot product of this vector with the provided vector.
      Parameter:
      other - the vector to calculate the dot product with.
      Gibt zurück:
      the resulting dot product.
    • dot

      public float dot(int x, int y, int z)
      Gets the dot product of this vector with the provided coordinates.
      Parameter:
      x - the x coordinate.
      y - the y coordinate.
      z - the z coordinate.
      Gibt zurück:
      the resulting dot product.
    • length

      public float length()
      Gets the length of this vector.
      Gibt zurück:
      the length of this vector.
      Siehe auch:
    • lengthSquared

      public float lengthSquared()
      Gets the squared length of this vector. Use this function to avoid calculating the squareroot.
      Gibt zurück:
      the squared length of this vector.
      Siehe auch:
    • distance

      public float distance(Vector3i other)
      Gets the distance between this vector and another vector.
      Parameter:
      other - the other vector.
      Gibt zurück:
      the distance between this vector and another vector.
      Siehe auch:
    • distance

      public float distance(int x, int y, int z)
      Gets the distance between this vector and the provided coordinates.
      Parameter:
      x - the other x coordinate.
      y - the other y coordinate.
      z - the other z coordinate.
      Gibt zurück:
      the distance between this vector and the provided coordinates.
      Siehe auch:
    • distanceSquared

      public float distanceSquared(Vector3i other)
      Gets the squared distance between this vector and another Vector3i. Use this function to avoid calculating the squareroot.
      Parameter:
      other - the other Vector3i.
      Gibt zurück:
      the squared distance between this vector and the provided Vector3i.
    • distanceSquared

      public float distanceSquared(int x, int y, int z)
      Gets the squared distance between this vector and the provided coordinates. Use this function to avoid calculating the squareroot.
      Parameter:
      x - the other x coordinate.
      y - the other y coordinate.
      z - the other z coordinate.
      Gibt zurück:
      the squared distance between this vector and the provided coordinates.
    • addLocal

      public Vector3i addLocal(Vector3i other)
      Adds the values of the provided vector to the values of this vector.
      Parameter:
      other - the vector to add.
      Gibt zurück:
      this vector.
    • addLocal

      public Vector3i addLocal(int addX, int addY, int addZ)
      Adds the provided values to the values of this vector.
      Parameter:
      addX - the x value to add.
      addY - the y value to add.
      addZ - the z value to add.
      Gibt zurück:
      this vector.
    • subtractLocal

      public Vector3i subtractLocal(Vector3i other)
      Subtracts the values of the provided vector from the values of this vector.
      Parameter:
      other - the vector to subtract.
      Gibt zurück:
      this vector.
    • subtractLocal

      public Vector3i subtractLocal(int subtractX, int subtractY, int subtractZ)
      Subtracts the provided values from the values of this vector.
      Parameter:
      subtractX - the x value to subtract.
      subtractY - the y value to subtract.
      subtractZ - the z value to subtract.
      Gibt zurück:
      this vector.
    • multLocal

      public Vector3i multLocal(int scalar)
      Multiplies the values of this vector with the provided scalar.
      Parameter:
      scalar - the value to multiply this vector by.
      Gibt zurück:
      this vector.
    • multLocal

      public Vector3i multLocal(Vector3i other)
      Multiplies the values of this vector with the values of the provided vector.
      Parameter:
      other - the vector to multiply.
      Gibt zurück:
      this vector.
    • multLocal

      public Vector3i multLocal(int multX, int multY, int multZ)
      Multiplies the values of this vector with the provided values.
      Parameter:
      multX - the x value to multiply the x coordinate of this vector by.
      multY - the y value to multiply the y coordinate of this vector by.
      multZ - the z value to multiply the z coordinate of this vector by.
      Gibt zurück:
      this vector.
    • divideLocal

      public Vector3i divideLocal(int scalar)
    • divideLocal

      public Vector3i divideLocal(Vector3i other)
    • negateLocal

      public Vector3i negateLocal()
      Negates all values of this vector.
      Gibt zurück:
      this vector.
    • crossLocal

      public Vector3i crossLocal(Vector3i other)
      Calculates the cross product of this vector and another vector.
      Parameter:
      other - the other vector.
      Gibt zurück:
      this vector.
    • crossLocal

      public Vector3i crossLocal(int v2x, int v2y, int v2z)
      Calculates the cross product of this vector and the provided coordinates.
      Parameter:
      v2x - the other x coordinate.
      v2y - the other y coordinate.
      v2z - the other z coordinate.
      Gibt zurück:
      this vector.
    • normalizeLocal

      public Vector3i normalizeLocal()
      Normalizes this vector (i.e turn it into a unit vector).
      Gibt zurück:
      this vector (normalized).
    • angleBetween

      public float angleBetween(Vector3i other)
      Gets the angle between this vector and another vector.
      Please note: Both vectors need to be unit vectors (normalized).
      Parameter:
      other - the other vector (unit vector).
      Gibt zurück:
      the angle in degrees.
    • zero

      public Vector3i zero()
      Sets all values to 0 (same set set(0, 0, 0);).
      Gibt zurück:
      this vector.
    • isUnitVector

      public boolean isUnitVector()
      Checks if this vector is a unit vector.
      Gibt zurück:
      true if this is a unit vector, false if not.
    • isOrthogonal

      public boolean isOrthogonal(Vector3i other)
      Checks if this vector is orthogonal to another vector (i.e the angle between both vectors is ~ 90° degree).
      Parameter:
      other - the other vector.
      Gibt zurück:
      true if this vector is orthogonal to the other vector, false if not.
    • isOrthogonal

      public boolean isOrthogonal(int x, int y, int z)
      Checks if this vector is orthogonal to another vector (i.e the angle between both vectors is ~ 90° degree).
      Parameter:
      x - the x coordinate of the other vector.
      y - the y coordinate of the other vector.
      z - the z coordinate of the other vector.
      Gibt zurück:
      true if this vector is orthogonal to the other vector, false if not.
    • equals

      public boolean equals(Object o)
      Gets whether or not this vector is equal to another object. This function returns true, if the other object is a Vector3i and if it has exactly the same x, y and z values.
      Setzt außer Kraft:
      equals in Klasse Object
      Parameter:
      o - the object to compare to equality.
      Gibt zurück:
      true if the other object is a Vector3i and has the same values as this vector, false if not.
    • equals

      public boolean equals(int x, int y, int z)
    • hashCode

      public int hashCode()
      Gets a unique* hash code for this vector, based on its values. If two vectors have the same x, y and z values, they will return the same hash code.

      * Please keep in mind that the uniqueness is not fully reliable. There is always a small chance that collisions occur (i.e two completely different vectors return the same hash code). But usually the reliability is sufficient.
      Setzt außer Kraft:
      hashCode in Klasse Object
      Gibt zurück:
      the hash code for this vector.
    • toString

      public String toString()
      Gets a String representation of this vector, for example (23, -5)
      Setzt außer Kraft:
      toString in Klasse Object
      Gibt zurück:
      a string representing the values of this vector.