Package gaiasky.util.math
Class Vector3b
java.lang.Object
gaiasky.util.math.Vector3b
- All Implemented Interfaces:
Serializable
Vector of arbitrary precision floating point numbers using ApFloat.
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorDescriptionVector3b()
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 componentsCreates a vector from the given vectorVector3b
(org.apfloat.Apfloat x, org.apfloat.Apfloat y, org.apfloat.Apfloat z) Creates a vector with the given components -
Method Summary
Modifier and TypeMethodDescriptionadd
(double value) Adds the given value to all three components of the vector.add
(double... vals) Adds the given vector to this componentadd
(double x, double y, double z) Adds the given vector to this componentadd
(com.badlogic.gdx.math.Vector3 vec) double
Gets the angle in degrees between the two vectorsdouble
Gets the angle in degrees between the two vectorsdouble
Gets the angle in degrees between the two vectorsdouble
Gets the angle in degrees between the two vectorsclamp
(double min, double max) cpy()
crs
(double x, double y, double z) Sets this vector to the cross product between it and the other vector.Sets this vector to the cross product between it and the other vector.static Vector3b
Calculates the outer product of two given vectorsv
andw
and returns the result as a newGVector3d
.div
(org.apfloat.Apfloat num) org.apfloat.Apfloat
double
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
org.apfloat.Apfloat
dst
(double x, double y, double z) org.apfloat.Apfloat
org.apfloat.Apfloat
org.apfloat.Apfloat
Faster version ofdst(Vector3b)
, using an auxiliary vector.org.apfloat.Apfloat
org.apfloat.Apfloat
Faster version ofdst(Vector3d)
, using an auxiliary vector.org.apfloat.Apfloat
dst2
(double x, double y, double z) Returns the squared distance between this point and the given pointorg.apfloat.Apfloat
double
dst2d
(double x, double y, double z) double
double
double
dstd
(double x, double y, double z) double
double
boolean
com.badlogic.gdx.math.Matrix4
getMatrix
(com.badlogic.gdx.math.Matrix4 aux) Sets the matrix aux to a translation matrix using this vectorSets the matrix aux to a translation matrix using this vectorint
hashCode()
boolean
hasNaN()
boolean
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()
Left-multiplies the vector by the given matrix, assuming the fourth (w) component of the vector is 1.mul4x3
(double[] matrix) Left-multiplies the vector by the given 4x3 column major matrix.nor()
com.badlogic.gdx.math.Vector3
put
(com.badlogic.gdx.math.Vector3 vec) rotate
(double degrees, double axisX, double axisY, double axisZ) Rotates this vector by the given angle in degrees around the given axis.Rotates this vector by the given angle in degrees around the given axis.Scales a given vector with a scalar and add the result to this one, i.e.scl
(double scalar) scl
(double x, double y, double z) Scales this vector by the given valuesscl
(org.apfloat.Apfloat scl) set
(double[] vals) Sets the components from the array.set
(double x, double y, double z) Sets the vector to the given componentsset
(float[] vals) Sets the components from the array.set
(float x, float y, float z) Sets the vector to the given componentsset
(com.badlogic.gdx.math.Vector3 vec) set
(org.apfloat.Apfloat x, org.apfloat.Apfloat y, org.apfloat.Apfloat z) Sets the vector to the given componentssetFromSpherical
(double azimuthalAngle, double polarAngle) Sets the components from the given spherical coordinatesetLength
(double len) setLength2
(double len2) com.badlogic.gdx.math.Vector3
setVector3
(com.badlogic.gdx.math.Vector3 v) Returns set v to this vector by casting doubles to floats.Returns set v to this vector by casting Apfloats to doubles.setZero()
sub
(double value) Subtracts the given value from all components of this vectorsub
(double x, double y, double z) Subtracts the other vector from this vector.sub
(com.badlogic.gdx.math.Vector3 a_vec) toString()
com.badlogic.gdx.math.Vector3
tov3()
com.badlogic.gdx.math.Vector3
tov3
(com.badlogic.gdx.math.Vector3 out) tov3d()
com.badlogic.gdx.math.Vector3
Returns a vector3 representation of this vector by casting the doubles to floats.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()
-
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
-
div
-
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:
- Whether this and the other vector are equal
-
dstd
-
dstd
-
dst
-
dst
Faster version ofdst(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
-
dst
Faster version ofdst(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
- 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
-
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
Gets the angle in degrees between the two vectors -
anglePrecise
Gets the angle in degrees between the two vectors -
anglePrecise
Gets the angle in degrees between the two vectors -
hashCode
public int hashCode() -
equals
-
setZero
-
hasNaN
public boolean hasNaN()
-