Class Vector3Q

java.lang.Object
gaiasky.util.math.Vector3Q

public class Vector3Q extends Object
A vector-3 that uses Quadruple, 128-bit floating point numbers, as components. This provides 33-36 significant digits of precision.
  • Field Details

    • x

      public Quadruple x
      the x-component of this vector
    • y

      public Quadruple y
      the y-component of this vector
    • z

      public Quadruple z
      the z-component of this vector
  • Constructor Details

    • Vector3Q

      public Vector3Q()
      Constructs a vector at (0,0,0)
    • Vector3Q

      public Vector3Q(Quadruple x, Quadruple y, Quadruple z)
      Creates a vector with the given components
      Parameters:
      x - The x-component
      y - The y-component
      z - The z-component
    • Vector3Q

      public Vector3Q(double x, double y, double z)
      Creates a vector with the given components
      Parameters:
      x - The x-component
      y - The y-component
      z - The z-component
    • Vector3Q

      public Vector3Q(Vector3D vec)
    • Vector3Q

      public Vector3Q(Vector3Q vector)
      Creates a vector from the given vector
      Parameters:
      vector - The vector
    • Vector3Q

      public Vector3Q(double[] values)
      Creates a vector from the given array. The array must have at least 3 elements.
      Parameters:
      values - The array
  • Method Details

    • len

      public static double len(double x, double y, double z)
      Returns:
      The euclidean length
    • crs

      public static Vector3Q crs(Vector3Q v, Vector3Q w)
      Calculates the outer product of two given vectors v and w and returns the result as a new Vector3Q.
      Parameters:
      v - left operand
      w - right operand
      Returns:
      outer product of v and w
    • x

      public double x()
    • y

      public double y()
    • z

      public double z()
    • set

      public Vector3Q set(float x, float y, float z)
      Sets the vector to the given components
      Parameters:
      x - The x-component
      y - The y-component
      z - The z-component
      Returns:
      this vector for chaining
    • set

      public Vector3Q set(double x, double y, double z)
      Sets the vector to the given components
      Parameters:
      x - The x-component
      y - The y-component
      z - The z-component
      Returns:
      this vector for chaining
    • set

      public Vector3Q set(Quadruple x, Quadruple y, Quadruple z)
      Sets the vector to the given components
      Parameters:
      x - The x-component
      y - The y-component
      z - The z-component
      Returns:
      this vector for chaining
    • set

      public Vector3Q set(Vector3Q vec)
    • set

      public Vector3Q set(Vector3D vec)
    • set

      public Vector3Q set(com.badlogic.gdx.math.Vector3 vec)
    • put

      public com.badlogic.gdx.math.Vector3 put(com.badlogic.gdx.math.Vector3 vec)
    • tov3

      public com.badlogic.gdx.math.Vector3 tov3()
    • tov3

      public com.badlogic.gdx.math.Vector3 tov3(com.badlogic.gdx.math.Vector3 out)
    • put

      public Vector3D put(Vector3D vec)
    • tov3d

      public Vector3D tov3d()
    • tov3d

      public Vector3D tov3d(Vector3D out)
    • put

      public Vector3Q put(Vector3Q vec)
    • set

      public Vector3Q set(double[] vals)
      Sets the components from the array. The array must have at least 3 elements
      Parameters:
      vals - The array
      Returns:
      this vector for chaining
    • set

      public Vector3Q set(float[] vals)
      Sets the components from the array. The array must have at least 3 elements
      Parameters:
      vals - The array
      Returns:
      this vector for chaining
    • setFromSpherical

      public Vector3Q setFromSpherical(double azimuthalAngle, double polarAngle)
      Sets the components from the given spherical coordinate
      Parameters:
      azimuthalAngle - The angle between x-axis in radians [0, 2pi]
      polarAngle - The angle between z-axis in radians [0, pi]
      Returns:
      This vector for chaining
    • setToRandomDirection

      public Vector3Q setToRandomDirection()
    • cpy

      public Vector3Q cpy()
    • add

      public Vector3Q add(Vector3Q vec)
    • add

      public Vector3Q add(Vector3D vec)
    • add

      public Vector3Q add(com.badlogic.gdx.math.Vector3 vec)
    • add

      public Vector3Q add(double x, double y, double z)
      Adds the given vector to this component
      Parameters:
      x - The x-component of the other vector
      y - The y-component of the other vector
      z - The z-component of the other vector
      Returns:
      This vector for chaining.
    • add

      public Vector3Q add(double... vals)
      Adds the given vector to this component
      Parameters:
      vals - The 3-value double vector.
      Returns:
      This vector for chaining.
    • add

      public Vector3Q add(double value)
      Adds the given value to all three components of the vector.
      Parameters:
      value - The value
      Returns:
      This vector for chaining
    • sub

      public Vector3Q sub(Vector3Q vec)
    • sub

      public Vector3Q sub(com.badlogic.gdx.math.Vector3 a_vec)
    • sub

      public Vector3Q sub(Vector3D a_vec)
    • sub

      public Vector3Q sub(double x, double y, double z)
      Subtracts the other vector from this vector.
      Parameters:
      x - The x-component of the other vector
      y - The y-component of the other vector
      z - The z-component of the other vector
      Returns:
      This vector for chaining
    • sub

      public Vector3Q sub(double value)
      Subtracts the given value from all components of this vector
      Parameters:
      value - The value
      Returns:
      This vector for chaining
    • div

      public Vector3Q div(Quadruple num)
    • scl

      public Vector3Q scl(Quadruple scl)
    • scl

      public Vector3Q scl(double scalar)
    • scl

      public Vector3Q scl(Vector3Q vec)
    • scl

      public Vector3Q scl(double x, double y, double z)
      Scales this vector by the given values
      Parameters:
      x - X value
      y - Y value
      z - Z value
      Returns:
      This vector for chaining
    • mul

      public Vector3Q mul(Vector3Q vec)
    • div

      public Vector3Q div(Vector3Q vec)
    • lenDouble

      public double lenDouble()
    • lenF

      public float lenF()
    • len

      public Quadruple len()
    • len2D

      public double len2D()
    • len2

      public Quadruple len2()
    • idt

      public boolean idt(Vector3Q vec)
      Parameters:
      vec - The other vector
      Returns:
      Whether this and the other vector are equal
    • dstD

      public double dstD(Vector3Q vec)
    • dstD

      public double dstD(Vector3Q vec, Vector3Q aux)
    • dst

      public Quadruple dst(Vector3Q vec)
    • dst

      public Quadruple dst(Vector3Q vec, Vector3Q aux)
      Faster version of dst(Vector3Q), using an auxiliary vector.
      Parameters:
      vec - The vector to compute the distance to.
      aux - The auxiliary vector.
      Returns:
      The distance between the two points.
    • dst

      public Quadruple dst(Vector3D vec)
    • dst

      public Quadruple dst(Vector3D vec, Vector3Q aux)
      Faster version of dst(Vector3D), using an auxiliary vector.
      Parameters:
      vec - The vector to compute the distance to.
      aux - The auxiliary vector.
      Returns:
      The distance between the two points.
    • dstD

      public double dstD(double x, double y, double z)
    • dst

      public Quadruple dst(double x, double y, double z)
      Returns:
      the distance between this point and the given point
    • dst

      public Quadruple dst(double x, double y, double z, Vector3Q aux)
      Returns:
      the distance between this point and the given point
    • dst2D

      public double dst2D(Vector3Q vec)
    • dst2D

      public double dst2D(Vector3D vec)
    • dst2

      public Quadruple dst2(Vector3Q vec)
    • dst2D

      public double dst2D(double x, double y, double z)
    • dst2

      public Quadruple dst2(Vector3D vec)
    • dst2

      public Quadruple dst2(double x, double y, double z)
      Returns the squared distance between this point and the given point
      Parameters:
      x - The x-component of the other point
      y - The y-component of the other point
      z - The z-component of the other point
      Returns:
      The squared distance
    • nor

      public Vector3Q nor()
    • dot

      public double dot(Vector3D vec)
    • dotD

      public double dotD(Vector3Q vec)
    • dot

      public Quadruple dot(Vector3Q vec)
    • dot

      public Quadruple dot(Quadruple x, Quadruple y, Quadruple z)
      Returns the dot product between this and the given vector.
      Parameters:
      x - The x-component of the other vector
      y - The y-component of the other vector
      z - The z-component of the other vector
      Returns:
      The dot product
    • crs

      public Vector3Q crs(Vector3Q vec)
      Sets this vector to the cross product between it and the other vector.
      Parameters:
      vec - The other vector
      Returns:
      This vector for chaining
    • crs

      public Vector3Q crs(Vector3D vec)
    • crs

      public Vector3Q crs(double x, double y, double z)
      Sets this vector to the cross product between it and the other vector.
      Parameters:
      x - The x-component of the other vector
      y - The y-component of the other vector
      z - The z-component of the other vector
      Returns:
      This vector for chaining
    • mul4x3

      public Vector3Q mul4x3(double[] matrix)
      Left-multiplies the vector by the given 4x3 column major matrix. The matrix should be composed by a 3x3 matrix representing rotation and scale plus a 1x3 matrix representing the translation.
      Parameters:
      matrix - The matrix
      Returns:
      This vector for chaining
    • mul

      public Vector3Q mul(Matrix4D matrix)
      Left-multiplies the vector by the given matrix, assuming the fourth (w) component of the vector is 1.
      Parameters:
      matrix - The matrix
      Returns:
      This vector for chaining
    • mul

      public Vector3Q mul(QuaternionDouble quat)
      Multiplies the vector by the given Quaternion.
      Returns:
      This vector for chaining
    • rotate

      public Vector3Q rotate(double degrees, double axisX, double axisY, double axisZ)
      Rotates this vector by the given angle in degrees around the given axis.
      Parameters:
      degrees - the angle in degrees
      axisX - the x-component of the axis
      axisY - the y-component of the axis
      axisZ - the z-component of the axis
      Returns:
      This vector for chaining
    • rotate

      public Vector3Q rotate(Vector3D axis, double degrees)
      Rotates this vector by the given angle in degrees around the given axis.
      Parameters:
      axis - the axis
      degrees - the angle in degrees
      Returns:
      This vector for chaining
    • setToTranslation

      public com.badlogic.gdx.math.Matrix4 setToTranslation(com.badlogic.gdx.math.Matrix4 matrix)
      Sets the given matrix to a translation matrix using this vector.
      Parameters:
      matrix - The matrix to set as a translation matrix.
      Returns:
      The matrix aux, for chaining.
    • setToTranslation

      public Matrix4D setToTranslation(Matrix4D matrix)
      Sets the given matrix to a translation matrix using this vector.
      Parameters:
      matrix - The matrix to set as a translation matrix.
      Returns:
      The matrix aux, for chaining.
    • isUnit

      public boolean isUnit()
    • isUnit

      public boolean isUnit(double margin)
    • isZero

      public boolean isZero()
    • isZero

      public boolean isZero(double margin)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setLength

      public Vector3Q setLength(double len)
    • setLength2

      public Vector3Q setLength2(double len2)
    • clamp

      public Vector3Q clamp(double min, double max)
    • values

      public Quadruple[] values()
    • valuesD

      public double[] valuesD()
    • valuesF

      public float[] valuesF()
    • valuesF

      public float[] valuesF(float[] vec)
    • angle

      public double angle(Vector3Q v)
      Gets the angle in degrees between the two vectors
    • angle

      public double angle(Vector3D v)
      Gets the angle in degrees between the two vectors
    • anglePrecise

      public double anglePrecise(Vector3Q v)
      Gets the angle in degrees between the two vectors
    • anglePrecise

      public double anglePrecise(Vector3D v)
      Gets the angle in degrees between the two vectors
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • setZero

      public Vector3Q setZero()
    • hasNaN

      public boolean hasNaN()