Class Vector3b

java.lang.Object
gaiasky.util.math.Vector3b
All Implemented Interfaces:
Serializable

public class Vector3b extends Object implements Serializable
Vector of arbitrary precision floating point numbers using ApFloat.
See Also:
  • Field Details

    • x

      public org.apfloat.Apfloat x
      the x-component of this vector
    • y

      public org.apfloat.Apfloat y
      the y-component of this vector
    • z

      public org.apfloat.Apfloat z
      the z-component of this vector
    • X

      public static final Vector3b X
    • Y

      public static final Vector3b Y
    • Z

      public static final Vector3b Z
  • Constructor Details

    • Vector3b

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

      public Vector3b(org.apfloat.Apfloat x, org.apfloat.Apfloat y, org.apfloat.Apfloat z)
      Creates a vector with the given components
      Parameters:
      x - The x-component
      y - The y-component
      z - The z-component
    • Vector3b

      public Vector3b(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
    • Vector3b

      public Vector3b(Vector3d vec)
    • Vector3b

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

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

    • x

      public double x()
    • xb

      public org.apfloat.Apfloat xb()
    • y

      public double y()
    • yb

      public org.apfloat.Apfloat yb()
    • z

      public double z()
    • zb

      public org.apfloat.Apfloat zb()
    • set

      public Vector3b 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 Vector3b 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 Vector3b set(org.apfloat.Apfloat x, org.apfloat.Apfloat y, org.apfloat.Apfloat 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 Vector3b set(Vector3b vec)
    • set

      public Vector3b set(Vector3d vec)
    • set

      public Vector3b 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 Vector3b put(Vector3b vec)
    • set

      public Vector3b 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 Vector3b 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 Vector3b 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 Vector3b setToRandomDirection()
    • cpy

      public Vector3b cpy()
    • add

      public Vector3b add(Vector3b vec)
    • add

      public Vector3b add(Vector3d vec)
    • add

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

      public Vector3b 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 Vector3b add(double... vals)
      Adds the given vector to this component
      Parameters:
      vals - The 3-value double vector.
      Returns:
      This vector for chaining.
    • add

      public Vector3b 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 Vector3b sub(Vector3b vec)
    • sub

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

      public Vector3b sub(Vector3d a_vec)
    • sub

      public Vector3b 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 Vector3b sub(double value)
      Subtracts the given value from all components of this vector
      Parameters:
      value - The value
      Returns:
      This vector for chaining
    • div

      public Vector3b div(org.apfloat.Apfloat num)
    • scl

      public Vector3b scl(org.apfloat.Apfloat scl)
    • scl

      public Vector3b scl(double scalar)
    • scl

      public Vector3b scl(Vector3b vec)
    • scl

      public Vector3b 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
    • mulAdd

      public Vector3b mulAdd(Vector3b vec, double scalar)
    • mulAdd

      public Vector3b mulAdd(Vector3b vec, Vector3b mulVec)
    • mul

      public Vector3b mul(Vector3b vec)
    • div

      public Vector3b div(Vector3b vec)
    • len

      public static double len(double x, double y, double z)
      Returns:
      The euclidian length
    • lend

      public double lend()
    • lenf

      public float lenf()
    • len

      public org.apfloat.Apfloat len()
    • len2

      public static double len2(double x, double y, double z)
      Returns:
      The squared euclidian length
    • len2d

      public double len2d()
    • len2

      public org.apfloat.Apfloat len2()
    • idt

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

      public double dstd(Vector3b vec)
    • dstd

      public double dstd(Vector3b vec, Vector3b aux)
    • dst

      public org.apfloat.Apfloat dst(Vector3b vec)
    • dst

      public org.apfloat.Apfloat dst(Vector3b vec, Vector3b aux)
      Faster version of dst(Vector3b), 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 org.apfloat.Apfloat dst(Vector3d vec)
    • dst

      public org.apfloat.Apfloat dst(Vector3d vec, Vector3b 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 org.apfloat.Apfloat dst(double x, double y, double z)
      Returns:
      the distance between this point and the given point
    • dst

      public org.apfloat.Apfloat dst(double x, double y, double z, Vector3b aux)
      Returns:
      the distance between this point and the given point
    • dst2d

      public double dst2d(Vector3b vec)
    • dst2d

      public double dst2d(Vector3d vec)
    • dst2

      public org.apfloat.Apfloat dst2(Vector3b vec)
    • dst2d

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

      public org.apfloat.Apfloat 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 Vector3b nor()
    • dot

      public double dot(Vector3d vec)
    • dotd

      public double dotd(Vector3b vec)
    • dot

      public org.apfloat.Apfloat dot(Vector3b vec)
    • dotd

      public double dotd(double x, double y, double z)
    • dot

      public org.apfloat.Apfloat dot(org.apfloat.Apfloat x, org.apfloat.Apfloat y, org.apfloat.Apfloat 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 Vector3b crs(Vector3b 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 Vector3b crs(Vector3d vec)
    • crs

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

      public Vector3b 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 Vector3b 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 Vector3b 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
    • rotate

      public Vector3b 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 Vector3b 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 Vector3b setLength(double len)
    • setLength2

      public Vector3b setLength2(double len2)
    • clamp

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

      public org.apfloat.Apfloat[] values()
    • valuesd

      public double[] valuesd()
    • valuesf

      public float[] valuesf()
    • valuesf

      public float[] valuesf(float[] vec)
    • scaleAdd

      public Vector3b scaleAdd(double s, Vector3b v)
      Scales a given vector with a scalar and add the result to this one, i.e. this = this + s*v.
      Parameters:
      s - scalar scaling factor
      v - vector to scale
      Returns:
      vector modified in place
    • toVector3

      public com.badlogic.gdx.math.Vector3 toVector3()
      Returns a vector3 representation of this vector by casting the doubles to floats. This creates a new object
      Returns:
      The vector3 representation of this vector3d
    • toVector3d

      public Vector3d toVector3d()
      Returns a vector3d representation of this vector by casting the Apfloats to doubles. This creates a new object
      Returns:
      The vector3d representation of this vector3b
    • setVector3

      public com.badlogic.gdx.math.Vector3 setVector3(com.badlogic.gdx.math.Vector3 v)
      Returns set v to this vector by casting doubles to floats.
      Returns:
      The float vector v.
    • setVector3d

      public Vector3d setVector3d(Vector3d v)
      Returns set v to this vector by casting Apfloats to doubles.
      Returns:
      The double vector v.
    • angle

      public double angle(Vector3b 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(Vector3b 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 Vector3b setZero()
    • hasNaN

      public boolean hasNaN()