Package gaiasky.util.math
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
-
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 componentsVector3b(Vector3b vector)Creates a vector from the given vectorVector3b(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 Vector3badd(double value)Adds the given value to all three components of the vector.Vector3badd(double... vals)Adds the given vector to this componentVector3badd(double x, double y, double z)Adds the given vector to this componentVector3badd(com.badlogic.gdx.math.Vector3 vec)Vector3badd(Vector3b vec)Vector3badd(Vector3d vec)doubleangle(Vector3b v)Gets the angle in degrees between the two vectorsdoubleangle(Vector3d v)doubleanglePrecise(Vector3b v)Gets the angle in degrees between the two vectorsVector3bclamp(double min, double max)Vector3bcpy()Vector3bcrs(double x, double y, double z)Sets this vector to the cross product between it and the other vector.Vector3bcrs(Vector3b vec)Sets this vector to the cross product between it and the other vector.static Vector3bcrs(Vector3b v, Vector3b w)Calculates the outer product of two given vectorsvandwand returns the result as a newGVector3d.Vector3bcrs(Vector3d vec)Vector3bdiv(Vector3b vec)org.apfloat.Apfloatdot(Vector3b vec)doubledot(Vector3d vec)org.apfloat.Apfloatdot(org.apfloat.Apfloat x, org.apfloat.Apfloat y, org.apfloat.Apfloat z)Returns the dot product between this and the given vector.doubledotd(double x, double y, double z)doubledotd(Vector3b vec)org.apfloat.Apfloatdst(double x, double y, double z)org.apfloat.Apfloatdst(Vector3b vec)org.apfloat.Apfloatdst(Vector3d vec)org.apfloat.Apfloatdst2(double x, double y, double z)Returns the squared distance between this point and the given pointorg.apfloat.Apfloatdst2(Vector3b vec)doubledst2d(double x, double y, double z)doubledst2d(Vector3b vec)doubledst2d(Vector3d vec)doubledstd(double x, double y, double z)doubledstd(Vector3b vec)booleanequals(java.lang.Object obj)com.badlogic.gdx.math.Matrix4getMatrix(com.badlogic.gdx.math.Matrix4 aux)Sets the matrix aux to a translation matrix using this vectorMatrix4dgetMatrix(Matrix4d aux)Sets the matrix aux to a translation matrix using this vectorinthashCode()booleanhasNaN()booleanidt(Vector3b vec)booleanisUnit()booleanisUnit(double margin)booleanisZero()booleanisZero(double margin)org.apfloat.Apfloatlen()static doublelen(double x, double y, double z)org.apfloat.Apfloatlen2()static doublelen2(double x, double y, double z)doublelen2d()doublelend()floatlenf()Vector3bmul(Matrix4d matrix)Left-multiplies the vector by the given matrix, assuming the fourth (w) component of the vector is 1.Vector3bmul(Vector3b vec)Vector3bmul4x3(double[] matrix)Left-multiplies the vector by the given 4x3 column major matrix.Vector3bmulAdd(Vector3b vec, double scalar)Vector3bmulAdd(Vector3b vec, Vector3b mulVec)Vector3bnor()com.badlogic.gdx.math.Vector3put(com.badlogic.gdx.math.Vector3 vec)Vector3bput(Vector3b vec)Vector3dput(Vector3d vec)Vector3brotate(double degrees, double axisX, double axisY, double axisZ)Rotates this vector by the given angle in degrees around the given axis.Vector3brotate(Vector3d axis, double degrees)Rotates this vector by the given angle in degrees around the given axis.Vector3bscaleAdd(double s, Vector3b v)Scales a given vector with a scalar and add the result to this one, i.e.Vector3bscl(double scalar)Vector3bscl(double x, double y, double z)Scales this vector by the given valuesVector3bscl(Vector3b vec)Vector3bscl(org.apfloat.Apfloat scl)Vector3bset(double[] vals)Sets the components from the array.Vector3bset(double x, double y, double z)Sets the vector to the given componentsVector3bset(float[] vals)Sets the components from the array.Vector3bset(float x, float y, float z)Sets the vector to the given componentsVector3bset(com.badlogic.gdx.math.Vector3 vec)Vector3bset(Vector3b vec)Vector3bset(Vector3d vec)Vector3bset(org.apfloat.Apfloat x, org.apfloat.Apfloat y, org.apfloat.Apfloat z)Sets the vector to the given componentsVector3bsetFromSpherical(double azimuthalAngle, double polarAngle)Sets the components from the given spherical coordinateVector3bsetLength(double len)Vector3bsetLength2(double len2)Vector3bsetToRandomDirection()com.badlogic.gdx.math.Vector3setVector3(com.badlogic.gdx.math.Vector3 v)Returns set v to this vector by casting doubles to floats.Vector3dsetVector3d(Vector3d v)Returns set v to this vector by casting Apfloats to doubles.Vector3bsetZero()Vector3bsub(double value)Subtracts the given value from all components of this vectorVector3bsub(double x, double y, double z)Subtracts the other vector from this vector.Vector3bsub(com.badlogic.gdx.math.Vector3 a_vec)Vector3bsub(Vector3b vec)Vector3bsub(Vector3d a_vec)java.lang.StringtoString()com.badlogic.gdx.math.Vector3tov3()com.badlogic.gdx.math.Vector3tov3(com.badlogic.gdx.math.Vector3 out)Vector3dtov3d()Vector3dtov3d(Vector3d out)com.badlogic.gdx.math.Vector3toVector3()Returns a vector3 representation of this vector by casting the doubles to floats.Vector3dtoVector3d()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)doublex()org.apfloat.Apfloatxb()doubley()org.apfloat.Apfloatyb()doublez()org.apfloat.Apfloatzb()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Field Details
-
x
public org.apfloat.Apfloat xthe x-component of this vector -
y
public org.apfloat.Apfloat ythe y-component of this vector -
z
public org.apfloat.Apfloat zthe z-component of this vector -
X
-
Y
-
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-componenty- The y-componentz- The z-component
-
Vector3b
public Vector3b(double x, double y, double z)Creates a vector with the given components- Parameters:
x- The x-componenty- The y-componentz- The z-component
-
Vector3b
-
Vector3b
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
Sets the vector to the given components- Parameters:
x- The x-componenty- The y-componentz- The z-component- Returns:
- this vector for chaining
-
set
Sets the vector to the given components- Parameters:
x- The x-componenty- The y-componentz- The z-component- Returns:
- this vector for chaining
-
set
Sets the vector to the given components- Parameters:
x- The x-componenty- The y-componentz- The z-component- Returns:
- this vector for chaining
-
set
-
set
-
set
-
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
-
tov3d
-
tov3d
-
put
-
set
Sets the components from the array. The array must have at least 3 elements- Parameters:
vals- The array- Returns:
- this vector for chaining
-
set
Sets the components from the array. The array must have at least 3 elements- Parameters:
vals- The array- Returns:
- this vector for chaining
-
setFromSpherical
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
-
cpy
-
add
-
add
-
add
-
add
Adds the given vector to this component- Parameters:
x- The x-component of the other vectory- The y-component of the other vectorz- The z-component of the other vector- Returns:
- This vector for chaining.
-
add
Adds the given vector to this component- Parameters:
vals- The 3-value double vector.- Returns:
- This vector for chaining.
-
add
Adds the given value to all three components of the vector.- Parameters:
value- The value- Returns:
- This vector for chaining
-
sub
-
sub
-
sub
-
sub
Subtracts the other vector from this vector.- Parameters:
x- The x-component of the other vectory- The y-component of the other vectorz- The z-component of the other vector- Returns:
- This vector for chaining
-
sub
Subtracts the given value from all components of this vector- Parameters:
value- The value- Returns:
- This vector for chaining
-
scl
-
scl
-
scl
-
scl
Scales this vector by the given values- Parameters:
x- X valuey- Y valuez- Z value- Returns:
- This vector for chaining
-
mulAdd
-
mulAdd
-
mul
-
div
-
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
- Parameters:
vec- The other vector- Returns:
- Wether this and the other vector are equal
-
dstd
-
dst
-
dst
-
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
-
dst2d
-
dst2
-
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 pointy- The y-component of the other pointz- The z-component of the other point- Returns:
- The squared distance
-
nor
-
dot
-
dotd
-
dot
-
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 vectory- The y-component of the other vectorz- The z-component of the other vector- Returns:
- The dot product
-
crs
Sets this vector to the cross product between it and the other vector.- Parameters:
vec- The other vector- Returns:
- This vector for chaining
-
crs
-
crs
Calculates the outer product of two given vectorsvandwand returns the result as a newGVector3d.- Parameters:
v- left operandw- right operand- Returns:
- outer product of
vandw
-
crs
Sets this vector to the cross product between it and the other vector.- Parameters:
x- The x-component of the other vectory- The y-component of the other vectorz- The z-component of the other vector- Returns:
- This vector for chaining
-
mul4x3
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
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
Rotates this vector by the given angle in degrees around the given axis.- Parameters:
degrees- the angle in degreesaxisX- the x-component of the axisaxisY- the y-component of the axisaxisZ- the z-component of the axis- Returns:
- This vector for chaining
-
rotate
Rotates this vector by the given angle in degrees around the given axis.- Parameters:
axis- the axisdegrees- 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
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:
toStringin classjava.lang.Object
-
setLength
-
setLength2
-
clamp
-
values
public org.apfloat.Apfloat[] values() -
valuesd
public double[] valuesd() -
valuesf
public float[] valuesf() -
valuesf
public float[] valuesf(float[] vec) -
scaleAdd
Scales a given vector with a scalar and add the result to this one, i.e.this = this + s*v.- Parameters:
s- scalar scaling factorv- 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
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
Returns set v to this vector by casting Apfloats to doubles.- Returns:
- The double vector v.
-
angle
Gets the angle in degrees between the two vectors -
angle
-
anglePrecise
Gets the angle in degrees between the two vectors -
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)- Overrides:
equalsin classjava.lang.Object
-
setZero
-
hasNaN
public boolean hasNaN()
-