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 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 componentVector3b
add(double x, double y, double z)
Adds the given vector to this componentVector3b
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 vectorsdouble
angle(Vector3d v)
double
anglePrecise(Vector3b v)
Gets the angle in degrees between the two vectorsVector3b
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 vectorsv
andw
and returns the result as a newGVector3d
.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 pointorg.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 vectorMatrix4d
getMatrix(Matrix4d aux)
Sets the matrix aux to a translation matrix using this vectorint
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 valuesVector3b
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 componentsVector3b
set(float[] vals)
Sets the components from the array.Vector3b
set(float x, float y, float z)
Sets the vector to the given componentsVector3b
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 componentsVector3b
setFromSpherical(double azimuthalAngle, double polarAngle)
Sets the components from the given spherical coordinateVector3b
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 vectorVector3b
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 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 vectorsv
andw
and returns the result as a newGVector3d
.- Parameters:
v
- left operandw
- right operand- Returns:
- outer product of
v
andw
-
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:
toString
in 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:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)- Overrides:
equals
in classjava.lang.Object
-
setZero
-
hasNaN
public boolean hasNaN()
-