Class Vector3b

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

public class Vector3b
extends java.lang.Object
implements java.io.Serializable
Vector of arbitrary precision floating point numbers using ApFloat.
See Also:
Serialized Form
  • Field Summary

    Fields
    Modifier and Type Field Description
    org.apfloat.Apfloat x
    the x-component of this vector
    static Vector3b X  
    org.apfloat.Apfloat y
    the y-component of this vector
    static Vector3b Y  
    org.apfloat.Apfloat z
    the z-component of this vector
    static Vector3b Z  
  • Constructor Summary

    Constructors
    Constructor Description
    Vector3b()
    Constructs a vector at (0,0,0)
    Vector3b​(double[] values)
    Creates a vector from the given array.
    Vector3b​(double x, double y, double z)
    Creates a vector with the given components
    Vector3b​(Vector3b vector)
    Creates a vector from the given vector
    Vector3b​(Vector3d vec)  
    Vector3b​(org.apfloat.Apfloat x, org.apfloat.Apfloat y, org.apfloat.Apfloat z)
    Creates a vector with the given components
  • Method Summary

    Modifier and Type Method Description
    Vector3b add​(double value)
    Adds the given value to all three components of the vector.
    Vector3b add​(double... vals)
    Adds the given vector to this component
    Vector3b add​(double x, double y, double z)
    Adds the given vector to this component
    Vector3b add​(com.badlogic.gdx.math.Vector3 vec)  
    Vector3b add​(Vector3b vec)  
    Vector3b add​(Vector3d vec)  
    double angle​(Vector3b v)
    Gets the angle in degrees between the two vectors
    double angle​(Vector3d v)  
    double anglePrecise​(Vector3b v)
    Gets the angle in degrees between the two vectors
    Vector3b clamp​(double min, double max)  
    Vector3b cpy()  
    Vector3b crs​(double x, double y, double z)
    Sets this vector to the cross product between it and the other vector.
    Vector3b crs​(Vector3b vec)
    Sets this vector to the cross product between it and the other vector.
    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.
    Vector3b crs​(Vector3d vec)  
    Vector3b div​(Vector3b vec)  
    org.apfloat.Apfloat dot​(Vector3b vec)  
    double dot​(Vector3d vec)  
    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.
    double dotd​(double x, double y, double z)  
    double dotd​(Vector3b vec)  
    org.apfloat.Apfloat dst​(double x, double y, double z)  
    org.apfloat.Apfloat dst​(Vector3b vec)  
    org.apfloat.Apfloat dst​(Vector3d vec)  
    org.apfloat.Apfloat dst2​(double x, double y, double z)
    Returns the squared distance between this point and the given point
    org.apfloat.Apfloat dst2​(Vector3b vec)  
    double dst2d​(double x, double y, double z)  
    double dst2d​(Vector3b vec)  
    double dst2d​(Vector3d vec)  
    double dstd​(double x, double y, double z)  
    double dstd​(Vector3b vec)  
    boolean equals​(java.lang.Object obj)  
    com.badlogic.gdx.math.Matrix4 getMatrix​(com.badlogic.gdx.math.Matrix4 aux)
    Sets the matrix aux to a translation matrix using this vector
    Matrix4d getMatrix​(Matrix4d aux)
    Sets the matrix aux to a translation matrix using this vector
    int hashCode()  
    boolean hasNaN()  
    boolean idt​(Vector3b vec)  
    boolean isUnit()  
    boolean isUnit​(double margin)  
    boolean isZero()  
    boolean isZero​(double margin)  
    org.apfloat.Apfloat len()  
    static double len​(double x, double y, double z)  
    org.apfloat.Apfloat len2()  
    static double len2​(double x, double y, double z)  
    double len2d()  
    double lend()  
    float lenf()  
    Vector3b mul​(Matrix4d matrix)
    Left-multiplies the vector by the given matrix, assuming the fourth (w) component of the vector is 1.
    Vector3b mul​(Vector3b vec)  
    Vector3b mul4x3​(double[] matrix)
    Left-multiplies the vector by the given 4x3 column major matrix.
    Vector3b mulAdd​(Vector3b vec, double scalar)  
    Vector3b mulAdd​(Vector3b vec, Vector3b mulVec)  
    Vector3b nor()  
    com.badlogic.gdx.math.Vector3 put​(com.badlogic.gdx.math.Vector3 vec)  
    Vector3b put​(Vector3b vec)  
    Vector3d put​(Vector3d vec)  
    Vector3b rotate​(double degrees, double axisX, double axisY, double axisZ)
    Rotates this vector by the given angle in degrees around the given axis.
    Vector3b rotate​(Vector3d axis, double degrees)
    Rotates this vector by the given angle in degrees around the given axis.
    Vector3b scaleAdd​(double s, Vector3b v)
    Scales a given vector with a scalar and add the result to this one, i.e.
    Vector3b scl​(double scalar)  
    Vector3b scl​(double x, double y, double z)
    Scales this vector by the given values
    Vector3b scl​(Vector3b vec)  
    Vector3b scl​(org.apfloat.Apfloat scl)  
    Vector3b set​(double[] vals)
    Sets the components from the array.
    Vector3b set​(double x, double y, double z)
    Sets the vector to the given components
    Vector3b set​(float[] vals)
    Sets the components from the array.
    Vector3b set​(float x, float y, float z)
    Sets the vector to the given components
    Vector3b set​(com.badlogic.gdx.math.Vector3 vec)  
    Vector3b set​(Vector3b vec)  
    Vector3b set​(Vector3d vec)  
    Vector3b set​(org.apfloat.Apfloat x, org.apfloat.Apfloat y, org.apfloat.Apfloat z)
    Sets the vector to the given components
    Vector3b setFromSpherical​(double azimuthalAngle, double polarAngle)
    Sets the components from the given spherical coordinate
    Vector3b setLength​(double len)  
    Vector3b setLength2​(double len2)  
    Vector3b setToRandomDirection()  
    com.badlogic.gdx.math.Vector3 setVector3​(com.badlogic.gdx.math.Vector3 v)
    Returns set v to this vector by casting doubles to floats.
    Vector3d setVector3d​(Vector3d v)
    Returns set v to this vector by casting Apfloats to doubles.
    Vector3b setZero()  
    Vector3b sub​(double value)
    Subtracts the given value from all components of this vector
    Vector3b sub​(double x, double y, double z)
    Subtracts the other vector from this vector.
    Vector3b sub​(com.badlogic.gdx.math.Vector3 a_vec)  
    Vector3b sub​(Vector3b vec)  
    Vector3b sub​(Vector3d a_vec)  
    java.lang.String toString()  
    com.badlogic.gdx.math.Vector3 tov3()  
    com.badlogic.gdx.math.Vector3 tov3​(com.badlogic.gdx.math.Vector3 out)  
    Vector3d tov3d()  
    Vector3d tov3d​(Vector3d out)  
    com.badlogic.gdx.math.Vector3 toVector3()
    Returns a vector3 representation of this vector by casting the doubles to floats.
    Vector3d toVector3d()
    Returns a vector3d representation of this vector by casting the Apfloats to doubles.
    org.apfloat.Apfloat[] values()  
    double[] valuesd()  
    float[] valuesf()  
    float[] valuesf​(float[] vec)  
    double x()  
    org.apfloat.Apfloat xb()  
    double y()  
    org.apfloat.Apfloat yb()  
    double z()  
    org.apfloat.Apfloat zb()  

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • 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
    • 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:
      Wether this and the other vector are equal
    • dstd

      public double dstd​(Vector3b vec)
    • dst

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

      public org.apfloat.Apfloat dst​(Vector3d vec)
    • 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
    • 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
    • getMatrix

      public com.badlogic.gdx.math.Matrix4 getMatrix​(com.badlogic.gdx.math.Matrix4 aux)
      Sets the matrix aux to a translation matrix using this vector
      Parameters:
      aux -
      Returns:
      The matrix aux
    • getMatrix

      public Matrix4d getMatrix​(Matrix4d aux)
      Sets the matrix aux to a translation matrix using this vector
      Parameters:
      aux -
      Returns:
      The matrix aux
    • isUnit

      public boolean isUnit()
    • isUnit

      public boolean isUnit​(double margin)
    • isZero

      public boolean isZero()
    • isZero

      public boolean isZero​(double margin)
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.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)
    • anglePrecise

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

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

      public boolean equals​(java.lang.Object obj)
      Overrides:
      equals in class java.lang.Object
    • setZero

      public Vector3b setZero()
    • hasNaN

      public boolean hasNaN()