public class Vector3 extends Object implements Serializable, Vector<Vector3>
Modifier and Type | Field and Description |
---|---|
float |
x
the x-component of this vector
|
static Vector3 |
X |
float |
y
the y-component of this vector
|
static Vector3 |
Y |
float |
z
the z-component of this vector
|
static Vector3 |
Z |
static Vector3 |
Zero |
Constructor and Description |
---|
Vector3()
Constructs a vector at (0,0,0)
|
Vector3(float[] values)
Creates a vector from the given array.
|
Vector3(float x,
float y,
float z)
Creates a vector with the given components
|
Vector3(Vector2 vector,
float z)
Creates a vector from the given vector and z-component
|
Vector3(Vector3 vector)
Creates a vector from the given vector
|
Modifier and Type | Method and Description |
---|---|
Vector3 |
add(float values)
Adds the given value to all three components of the vector.
|
Vector3 |
add(float x,
float y,
float z)
Adds the given vector to this component
|
Vector3 |
add(Vector3 vector)
Adds the given vector to this vector
|
Vector3 |
clamp(float min,
float max)
Clamps this vector's length to given min and max values
|
Vector3 |
cpy() |
Vector3 |
crs(float x,
float y,
float z)
Sets this vector to the cross product between it and the other vector.
|
Vector3 |
crs(Vector3 vector)
Sets this vector to the cross product between it and the other vector.
|
float |
dot(float x,
float y,
float z)
Returns the dot product between this and the given vector.
|
static float |
dot(float x1,
float y1,
float z1,
float x2,
float y2,
float z2) |
float |
dot(Vector3 vector) |
float |
dst(float x,
float y,
float z) |
static float |
dst(float x1,
float y1,
float z1,
float x2,
float y2,
float z2) |
float |
dst(Vector3 vector) |
float |
dst2(float x,
float y,
float z)
Returns the squared distance between this point and the given point
|
static float |
dst2(float x1,
float y1,
float z1,
float x2,
float y2,
float z2) |
float |
dst2(Vector3 point)
This method is faster than
Vector.dst(Vector) because it avoids calculating a square root. |
boolean |
epsilonEquals(float x,
float y,
float z,
float epsilon)
Compares this vector with the other vector, using the supplied epsilon for fuzzy equality testing.
|
boolean |
epsilonEquals(Vector3 other,
float epsilon)
Compares this vector with the other vector, using the supplied epsilon for fuzzy equality testing.
|
boolean |
equals(Object obj) |
int |
hashCode() |
boolean |
hasOppositeDirection(Vector3 vector) |
boolean |
hasSameDirection(Vector3 vector) |
boolean |
idt(Vector3 vector) |
Vector3 |
interpolate(Vector3 target,
float alpha,
Interpolation interpolator)
Interpolates between this vector and the given target vector by alpha (within range [0,1]) using the given Interpolation
method.
|
boolean |
isCollinear(Vector3 other) |
boolean |
isCollinear(Vector3 other,
float epsilon) |
boolean |
isCollinearOpposite(Vector3 other) |
boolean |
isCollinearOpposite(Vector3 other,
float epsilon) |
boolean |
isOnLine(Vector3 other) |
boolean |
isOnLine(Vector3 other,
float epsilon) |
boolean |
isPerpendicular(Vector3 vector) |
boolean |
isPerpendicular(Vector3 vector,
float epsilon) |
boolean |
isUnit() |
boolean |
isUnit(float margin) |
boolean |
isZero() |
boolean |
isZero(float margin) |
float |
len() |
static float |
len(float x,
float y,
float z) |
float |
len2()
This method is faster than
Vector.len() because it avoids calculating a square root. |
static float |
len2(float x,
float y,
float z) |
Vector3 |
lerp(Vector3 target,
float alpha)
Linearly interpolates between this vector and the target vector by alpha which is in the range [0,1].
|
Vector3 |
limit(float limit)
Limits the length of this vector, based on the desired maximum length.
|
Vector3 |
limit2(float limit2)
Limits the length of this vector, based on the desired maximum length squared.
|
Vector3 |
mul(Matrix3 matrix)
Left-multiplies the vector by the given matrix.
|
Vector3 |
mul(Matrix4 matrix)
Left-multiplies the vector by the given matrix, assuming the fourth (w) component of the vector is 1.
|
Vector3 |
mul(Quaternion quat)
Multiplies the vector by the given
Quaternion . |
Vector3 |
mul4x3(float[] matrix)
Left-multiplies the vector by the given 4x3 column major matrix.
|
Vector3 |
mulAdd(Vector3 vec,
float scalar)
First scale a supplied vector, then add it to this vector.
|
Vector3 |
mulAdd(Vector3 vec,
Vector3 mulVec)
First scale a supplied vector, then add it to this vector.
|
Vector3 |
nor()
Normalizes this vector.
|
Vector3 |
prj(Matrix4 matrix)
Multiplies this vector by the given matrix dividing by w, assuming the fourth (w) component of the vector is 1.
|
Vector3 |
rot(Matrix4 matrix)
Multiplies this vector by the first three columns of the matrix, essentially only applying rotation and scaling.
|
Vector3 |
rotate(float degrees,
float axisX,
float axisY,
float axisZ)
Rotates this vector by the given angle in degrees around the given axis.
|
Vector3 |
rotate(Vector3 axis,
float degrees)
Rotates this vector by the given angle in degrees around the given axis.
|
Vector3 |
rotateRad(float radians,
float axisX,
float axisY,
float axisZ)
Rotates this vector by the given angle in radians around the given axis.
|
Vector3 |
rotateRad(Vector3 axis,
float radians)
Rotates this vector by the given angle in radians around the given axis.
|
Vector3 |
scl(float scalar)
Scales this vector by a scalar
|
Vector3 |
scl(float vx,
float vy,
float vz)
Scales this vector by the given values
|
Vector3 |
scl(Vector3 other)
Scales this vector by another vector
|
Vector3 |
set(float[] values)
Sets the components from the array.
|
Vector3 |
set(float x,
float y,
float z)
Sets the vector to the given components
|
Vector3 |
set(Vector2 vector,
float z)
Sets the components of the given vector and z-component
|
Vector3 |
set(Vector3 vector)
Sets this vector from the given vector
|
Vector3 |
setLength(float len)
Sets the length of this vector.
|
Vector3 |
setLength2(float len2)
Sets the length of this vector, based on the square of the desired length.
|
Vector3 |
setZero()
Sets the components of this vector to 0
|
Vector3 |
slerp(Vector3 target,
float alpha)
Spherically interpolates between this vector and the target vector by alpha which is in the range [0,1].
|
Vector3 |
sub(float value)
Subtracts the given value from all components of this vector
|
Vector3 |
sub(float x,
float y,
float z)
Subtracts the other vector from this vector.
|
Vector3 |
sub(Vector3 a_vec)
Subtracts the given vector from this vector.
|
String |
toString() |
Vector3 |
traMul(Matrix3 matrix)
Multiplies the vector by the transpose of the given matrix.
|
Vector3 |
traMul(Matrix4 matrix)
Multiplies the vector by the transpose of the given matrix, assuming the fourth (w) component of the vector is 1.
|
Vector3 |
unrotate(Matrix4 matrix)
Multiplies this vector by the transpose of the first three columns of the matrix.
|
Vector3 |
untransform(Matrix4 matrix)
Translates this vector in the direction opposite to the translation of the matrix and the multiplies this vector by the
transpose of the first three columns of the matrix.
|
public float x
public float y
public float z
public static final Vector3 X
public static final Vector3 Y
public static final Vector3 Z
public static final Vector3 Zero
public Vector3()
public Vector3(float x, float y, float z)
x
- The x-componenty
- The y-componentz
- The z-componentpublic Vector3(Vector3 vector)
vector
- The vectorpublic Vector3(float[] values)
values
- The arraypublic Vector3(Vector2 vector, float z)
vector
- The vectorz
- The z-componentpublic Vector3 set(float x, float y, float z)
x
- The x-componenty
- The y-componentz
- The z-componentpublic Vector3 set(Vector3 vector)
Vector
public Vector3 set(float[] values)
values
- The arraypublic Vector3 set(Vector2 vector, float z)
vector
- The vectorz
- The z-componentpublic Vector3 cpy()
public Vector3 add(Vector3 vector)
Vector
public Vector3 add(float x, float y, float z)
x
- The x-component of the other vectory
- The y-component of the other vectorz
- The z-component of the other vectorpublic Vector3 add(float values)
values
- The valuepublic Vector3 sub(Vector3 a_vec)
Vector
public Vector3 sub(float x, float y, float z)
x
- The x-component of the other vectory
- The y-component of the other vectorz
- The z-component of the other vectorpublic Vector3 sub(float value)
value
- The valuepublic Vector3 scl(float scalar)
Vector
public Vector3 scl(Vector3 other)
Vector
public Vector3 scl(float vx, float vy, float vz)
vx
- X valuevy
- Y valuevz
- Z valuepublic Vector3 mulAdd(Vector3 vec, float scalar)
Vector
public Vector3 mulAdd(Vector3 vec, Vector3 mulVec)
Vector
public static float len(float x, float y, float z)
public static float len2(float x, float y, float z)
public float len2()
Vector
Vector.len()
because it avoids calculating a square root. It is useful for comparisons,
but not for getting exact lengths, as the return value is the square of the actual length.public boolean idt(Vector3 vector)
vector
- The other vectorpublic static float dst(float x1, float y1, float z1, float x2, float y2, float z2)
public float dst(Vector3 vector)
public float dst(float x, float y, float z)
public static float dst2(float x1, float y1, float z1, float x2, float y2, float z2)
public float dst2(Vector3 point)
Vector
Vector.dst(Vector)
because it avoids calculating a square root. It is useful for
comparisons, but not for getting accurate distances, as the return value is the square of the actual distance.public float dst2(float x, float y, float z)
x
- The x-component of the other pointy
- The y-component of the other pointz
- The z-component of the other pointpublic Vector3 nor()
Vector
public static float dot(float x1, float y1, float z1, float x2, float y2, float z2)
public float dot(Vector3 vector)
public float dot(float x, float y, float z)
x
- The x-component of the other vectory
- The y-component of the other vectorz
- The z-component of the other vectorpublic Vector3 crs(Vector3 vector)
vector
- The other vectorpublic Vector3 crs(float x, float y, float z)
x
- The x-component of the other vectory
- The y-component of the other vectorz
- The z-component of the other vectorpublic Vector3 mul4x3(float[] matrix)
matrix
- The matrixpublic Vector3 mul(Matrix4 matrix)
matrix
- The matrixpublic Vector3 traMul(Matrix4 matrix)
matrix
- The matrixpublic Vector3 mul(Matrix3 matrix)
matrix
- The matrixpublic Vector3 traMul(Matrix3 matrix)
matrix
- The matrixpublic Vector3 mul(Quaternion quat)
Quaternion
.public Vector3 prj(Matrix4 matrix)
matrix
- The matrix.public Vector3 rot(Matrix4 matrix)
matrix
- The matrixpublic Vector3 unrotate(Matrix4 matrix)
rot(Matrix4)
with Matrix4.inv()
.matrix
- The transformation matrixpublic Vector3 untransform(Matrix4 matrix)
mul(Matrix4)
with Matrix4.inv()
.matrix
- The transformation matrixpublic Vector3 rotate(float degrees, float axisX, float axisY, float axisZ)
degrees
- the angle in degreesaxisX
- the x-component of the axisaxisY
- the y-component of the axisaxisZ
- the z-component of the axispublic Vector3 rotateRad(float radians, float axisX, float axisY, float axisZ)
radians
- the angle in radiansaxisX
- the x-component of the axisaxisY
- the y-component of the axisaxisZ
- the z-component of the axispublic Vector3 rotate(Vector3 axis, float degrees)
axis
- the axisdegrees
- the angle in degreespublic Vector3 rotateRad(Vector3 axis, float radians)
axis
- the axisradians
- the angle in radianspublic boolean isUnit()
public boolean isUnit(float margin)
public boolean isZero()
public boolean isZero(float margin)
public boolean isOnLine(Vector3 other, float epsilon)
public boolean isOnLine(Vector3 other)
public boolean isCollinear(Vector3 other, float epsilon)
isCollinear
in interface Vector<Vector3>
Vector.isOnLine(Vector, float)
&&
Vector.hasSameDirection(Vector)
).public boolean isCollinear(Vector3 other)
isCollinear
in interface Vector<Vector3>
Vector.isOnLine(Vector)
&&
Vector.hasSameDirection(Vector)
).public boolean isCollinearOpposite(Vector3 other, float epsilon)
isCollinearOpposite
in interface Vector<Vector3>
Vector.isOnLine(Vector, float)
&&
Vector.hasOppositeDirection(Vector)
).public boolean isCollinearOpposite(Vector3 other)
isCollinearOpposite
in interface Vector<Vector3>
Vector.isOnLine(Vector)
&&
Vector.hasOppositeDirection(Vector)
).public boolean isPerpendicular(Vector3 vector)
isPerpendicular
in interface Vector<Vector3>
public boolean isPerpendicular(Vector3 vector, float epsilon)
isPerpendicular
in interface Vector<Vector3>
epsilon
- a positive small number close to zeropublic boolean hasSameDirection(Vector3 vector)
hasSameDirection
in interface Vector<Vector3>
public boolean hasOppositeDirection(Vector3 vector)
hasOppositeDirection
in interface Vector<Vector3>
public Vector3 lerp(Vector3 target, float alpha)
Vector
public Vector3 interpolate(Vector3 target, float alpha, Interpolation interpolator)
Vector
interpolate
in interface Vector<Vector3>
target
- The target vectoralpha
- The interpolation coefficientinterpolator
- An Interpolation object describing the used interpolation methodpublic Vector3 slerp(Vector3 target, float alpha)
target
- The target vectoralpha
- The interpolation coefficientpublic Vector3 limit(float limit)
Vector
public Vector3 limit2(float limit2)
Vector
limit2
in interface Vector<Vector3>
limit2
- squared desired maximum length for this vectorVector.len2()
public Vector3 setLength(float len)
Vector
public Vector3 setLength2(float len2)
Vector
setLength2
in interface Vector<Vector3>
len2
- desired square of the length for this vectorVector.len2()
public Vector3 clamp(float min, float max)
Vector
public boolean epsilonEquals(Vector3 other, float epsilon)
Vector
epsilonEquals
in interface Vector<Vector3>
public boolean epsilonEquals(float x, float y, float z, float epsilon)
Copyright © 2015. All rights reserved.