Class Vector3Q
java.lang.Object
gaiasky.util.math.Vector3Q
-
Field Summary
Fields -
Constructor Summary
Constructors -
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) doubleGets the angle in degrees between the two vectorsdoubleGets the angle in degrees between the two vectorsdoubleGets the angle in degrees between the two vectorsdoubleGets 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 Vector3QReturns the dot product between this and the given vector.doubledoubledst(double x, double y, double z) Faster version ofdst(Vector3D), using an auxiliary vector.Faster version ofdst(Vector3Q), using an auxiliary vector.dst2(double x, double y, double z) Returns the squared distance between this point and the given pointdoubledst2D(double x, double y, double z) doubledoubledoubledstD(double x, double y, double z) doubledoublebooleaninthashCode()booleanhasNaN()booleanbooleanisUnit()booleanisUnit(double margin) booleanisZero()booleanisZero(double margin) len()static doublelen(double x, double y, double z) len2()doublelen2D()doublefloatlenF()Left-multiplies the vector by the given matrix, assuming the fourth (w) component of the vector is 1.mul(QuaternionDouble quat) Multiplies the vector by the givenQuaternion.mul4x3(double[] matrix) Left-multiplies the vector by the given 4x3 column major matrix.nor()com.badlogic.gdx.math.Vector3put(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.scl(double scalar) scl(double x, double y, double z) Scales this vector by the given valuesset(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) 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.Matrix4setToTranslation(com.badlogic.gdx.math.Matrix4 matrix) Sets the given matrix to a translation matrix using this vector.setToTranslation(Matrix4D matrix) Sets the given matrix to a translation matrix using this vector.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.Vector3tov3()com.badlogic.gdx.math.Vector3tov3(com.badlogic.gdx.math.Vector3 out) tov3d()values()double[]valuesD()float[]valuesF()float[]valuesF(float[] vec) doublex()doubley()doublez()
-
Field Details
-
x
the x-component of this vector -
y
the y-component of this vector -
z
the z-component of this vector
-
-
Constructor Details
-
Vector3Q
public Vector3Q()Constructs a vector at (0,0,0) -
Vector3Q
-
Vector3Q
public Vector3Q(double x, double y, double z) Creates a vector with the given components- Parameters:
x- The x-componenty- The y-componentz- The z-component
-
Vector3Q
-
Vector3Q
Creates a vector from the given vector- Parameters:
vector- The vector
-
Vector3Q
public Vector3Q(double[] values) Creates a vector from the given array. The array must have at least 3 elements.- Parameters:
values- The array
-
-
Method Details
-
len
public static double len(double x, double y, double z) - Returns:
- The euclidean length
-
crs
-
x
public double x() -
y
public double y() -
z
public double z() -
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
-
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
-
mul
-
div
-
lenDouble
public double lenDouble() -
lenF
public float lenF() -
len
-
len2D
public double len2D() -
len2
-
idt
- Parameters:
vec- The other vector- Returns:
- Whether this and the other vector are equal
-
dstD
-
dstD
-
dst
-
dst
Faster version ofdst(Vector3Q), 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
- Returns:
- the distance between this point and the given point
-
dst
-
dst2D
-
dst2D
-
dst2
-
dst2D
public double dst2D(double x, double y, double z) -
dst2
-
dst2
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
-
dot
-
crs
-
crs
-
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
-
mul
Multiplies the vector by the givenQuaternion.- 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
-
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
-
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
-
valuesD
public double[] valuesD() -
valuesF
public float[] valuesF() -
valuesF
public float[] valuesF(float[] vec) -
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
-
equals
-
setZero
-
hasNaN
public boolean hasNaN()
-