public class Vector3f extends Object implements Externalizable, Vector3fc
| Modifier and Type | Field and Description |
|---|---|
float |
x
The x component of the vector.
|
float |
y
The y component of the vector.
|
float |
z
The z component of the vector.
|
| Constructor and Description |
|---|
Vector3f()
Create a new
Vector3f of (0, 0, 0). |
Vector3f(ByteBuffer buffer)
Create a new
Vector3f and read this vector from the supplied ByteBuffer
at the current buffer position. |
Vector3f(float d)
Create a new
Vector3f and initialize all three components with the given value. |
Vector3f(FloatBuffer buffer)
Create a new
Vector3f and read this vector from the supplied FloatBuffer
at the current buffer position. |
Vector3f(float x,
float y,
float z)
Create a new
Vector3f with the given component values. |
Vector3f(int index,
ByteBuffer buffer)
Create a new
Vector3f and read this vector from the supplied ByteBuffer
starting at the specified absolute buffer position/index. |
Vector3f(int index,
FloatBuffer buffer)
Create a new
Vector3f and read this vector from the supplied FloatBuffer
starting at the specified absolute buffer position/index. |
Vector3f(Vector2fc v,
float z)
|
Vector3f(Vector2ic v,
float z)
|
Vector3f(Vector3fc v)
Create a new
Vector3f with the same values as v. |
Vector3f(Vector3ic v)
Create a new
Vector3f with the same values as v. |
| Modifier and Type | Method and Description |
|---|---|
Vector3f |
absolute()
Set
this vector's components to their respective absolute values. |
Vector3f |
absolute(Vector3f dest)
Compute the absolute values of the individual components of
this and store the result in dest. |
Vector3f |
add(float x,
float y,
float z)
Increment the components of this vector by the given values.
|
Vector3f |
add(float x,
float y,
float z,
Vector3f dest)
Increment the components of this vector by the given values and store the result in
dest. |
Vector3f |
add(Vector3fc v)
Add the supplied vector to this one.
|
Vector3f |
add(Vector3fc v,
Vector3f dest)
Add the supplied vector to this one and store the result in
dest. |
float |
angle(Vector3fc v)
Return the angle between this vector and the supplied vector.
|
float |
angleCos(Vector3fc v)
Return the cosine of the angle between this vector and the supplied vector.
|
float |
angleSigned(float x,
float y,
float z,
float nx,
float ny,
float nz)
Return the signed angle between this vector and the supplied vector with
respect to the plane with the given normal vector
(nx, ny, nz). |
float |
angleSigned(Vector3fc v,
Vector3fc n)
Return the signed angle between this vector and the supplied vector with
respect to the plane with the given normal vector
n. |
Vector3f |
ceil()
Set each component of this vector to the smallest (closest to negative
infinity)
float value that is greater than or equal to that
component and is equal to a mathematical integer. |
Vector3f |
ceil(Vector3f dest)
Compute for each component of this vector the smallest (closest to negative
infinity)
float value that is greater than or equal to that
component and is equal to a mathematical integer and store the result in
dest. |
Vector3f |
cross(float x,
float y,
float z)
Set this vector to be the cross product of itself and
(x, y, z). |
Vector3f |
cross(float x,
float y,
float z,
Vector3f dest)
Compute the cross product of this vector and
(x, y, z) and store the result in dest. |
Vector3f |
cross(Vector3fc v)
Set this vector to be the cross product of itself and
v. |
Vector3f |
cross(Vector3fc v,
Vector3f dest)
Compute the cross product of this vector and
v and store the result in dest. |
float |
distance(float x,
float y,
float z)
Return the distance between
this vector and (x, y, z). |
static float |
distance(float x1,
float y1,
float z1,
float x2,
float y2,
float z2)
Return the distance between
(x1, y1, z1) and (x2, y2, z2). |
float |
distance(Vector3fc v)
Return the distance between this Vector and
v. |
float |
distanceSquared(float x,
float y,
float z)
Return the square of the distance between
this vector and (x, y, z). |
static float |
distanceSquared(float x1,
float y1,
float z1,
float x2,
float y2,
float z2)
Return the squared distance between
(x1, y1, z1) and (x2, y2, z2). |
float |
distanceSquared(Vector3fc v)
Return the square of the distance between this vector and
v. |
Vector3f |
div(float scalar)
Divide all components of this
Vector3f by the given scalar
value. |
Vector3f |
div(float x,
float y,
float z)
Divide the components of this Vector3f by the given scalar values and store the result in
this. |
Vector3f |
div(float x,
float y,
float z,
Vector3f dest)
Divide the components of this Vector3f by the given scalar values and store the result in
dest. |
Vector3f |
div(float scalar,
Vector3f dest)
Divide all components of this
Vector3f by the given scalar
value and store the result in dest. |
Vector3f |
div(Vector3fc v)
Divide this Vector3f component-wise by another Vector3fc.
|
Vector3f |
div(Vector3fc v,
Vector3f dest)
Divide this Vector3f component-wise by another Vector3f and store the result in
dest. |
float |
dot(float x,
float y,
float z)
Return the dot product of this vector and the vector
(x, y, z). |
float |
dot(Vector3fc v)
Return the dot product of this vector and the supplied vector.
|
boolean |
equals(float x,
float y,
float z)
Compare the vector components of
this vector with the given (x, y, z)
and return whether all of them are equal. |
boolean |
equals(Object obj) |
boolean |
equals(Vector3fc v,
float delta)
Compare the vector components of
this vector with the given vector using the given delta
and return whether all of them are equal within a maximum difference of delta. |
Vector3f |
floor()
Set each component of this vector to the largest (closest to positive
infinity)
float value that is less than or equal to that
component and is equal to a mathematical integer. |
Vector3f |
floor(Vector3f dest)
Compute for each component of this vector the largest (closest to positive
infinity)
float value that is less than or equal to that
component and is equal to a mathematical integer and store the result in
dest. |
Vector3f |
fma(float a,
Vector3fc b)
Add the component-wise multiplication of
a * b to this vector. |
Vector3f |
fma(float a,
Vector3fc b,
Vector3f dest)
Add the component-wise multiplication of
a * b to this vector
and store the result in dest. |
Vector3f |
fma(Vector3fc a,
Vector3fc b)
Add the component-wise multiplication of
a * b to this vector. |
Vector3f |
fma(Vector3fc a,
Vector3fc b,
Vector3f dest)
Add the component-wise multiplication of
a * b to this vector
and store the result in dest. |
ByteBuffer |
get(ByteBuffer buffer)
Store this vector into the supplied
ByteBuffer at the current
buffer position. |
FloatBuffer |
get(FloatBuffer buffer)
Store this vector into the supplied
FloatBuffer at the current
buffer position. |
float |
get(int component)
Get the value of the specified component of this vector.
|
ByteBuffer |
get(int index,
ByteBuffer buffer)
Store this vector into the supplied
ByteBuffer starting at the specified
absolute buffer position/index. |
FloatBuffer |
get(int index,
FloatBuffer buffer)
Store this vector into the supplied
FloatBuffer starting at the specified
absolute buffer position/index. |
Vector3f |
half(float x,
float y,
float z)
Compute the half vector between this and the vector
(x, y, z). |
Vector3f |
half(float x,
float y,
float z,
Vector3f dest)
Compute the half vector between this and the vector
(x, y, z)
and store the result in dest. |
Vector3f |
half(Vector3fc other)
Compute the half vector between this and the other vector.
|
Vector3f |
half(Vector3fc other,
Vector3f dest)
Compute the half vector between this and the other vector and store the result in
dest. |
int |
hashCode() |
Vector3f |
hermite(Vector3fc t0,
Vector3fc v1,
Vector3fc t1,
float t,
Vector3f dest)
Compute a hermite interpolation between
this vector with its
associated tangent t0 and the given vector v
with its tangent t1 and store the result in
dest. |
boolean |
isFinite()
|
float |
length()
Return the length of this vector.
|
static float |
length(float x,
float y,
float z)
Get the length of a 3-dimensional single-precision vector.
|
float |
lengthSquared()
Return the length squared of this vector.
|
static float |
lengthSquared(float x,
float y,
float z)
Get the length squared of a 3-dimensional single-precision vector.
|
Vector3f |
lerp(Vector3fc other,
float t)
Linearly interpolate
this and other using the given interpolation factor t
and store the result in this. |
Vector3f |
lerp(Vector3fc other,
float t,
Vector3f dest)
Linearly interpolate
this and other using the given interpolation factor t
and store the result in dest. |
Vector3f |
max(Vector3fc v)
Set the components of this vector to be the component-wise maximum of this and the other vector.
|
Vector3f |
max(Vector3fc v,
Vector3f dest)
Set the components of
dest to be the component-wise maximum of this and the other vector. |
int |
maxComponent()
Determine the component with the biggest absolute value.
|
Vector3f |
min(Vector3fc v)
Set the components of this vector to be the component-wise minimum of this and the other vector.
|
Vector3f |
min(Vector3fc v,
Vector3f dest)
Set the components of
dest to be the component-wise minimum of this and the other vector. |
int |
minComponent()
Determine the component with the smallest (towards zero) absolute value.
|
Vector3f |
mul(float scalar)
Multiply all components of this
Vector3f by the given scalar
value. |
Vector3f |
mul(float x,
float y,
float z)
Multiply the components of this Vector3f by the given scalar values and store the result in
this. |
Vector3f |
mul(float x,
float y,
float z,
Vector3f dest)
Multiply the components of this Vector3f by the given scalar values and store the result in
dest. |
Vector3f |
mul(float scalar,
Vector3f dest)
Multiply all components of this
Vector3f by the given scalar
value and store the result in dest. |
Vector3f |
mul(Matrix3dc mat)
Multiply the given matrix with this Vector3f and store the result in
this. |
Vector3f |
mul(Matrix3dc mat,
Vector3f dest)
Multiply the given matrix with this Vector3f and store the result in
dest. |
Vector3f |
mul(Matrix3fc mat)
Multiply the given matrix with this Vector3f and store the result in
this. |
Vector3f |
mul(Matrix3fc mat,
Vector3f dest)
Multiply the given matrix with this Vector3f and store the result in
dest. |
Vector3f |
mul(Matrix3x2fc mat)
Multiply the given matrix with this Vector3f and store the result in
this. |
Vector3f |
mul(Matrix3x2fc mat,
Vector3f dest)
Multiply the given matrix
mat with this by assuming a
third row in the matrix of (0, 0, 1) and store the result in dest. |
Vector3f |
mul(Vector3fc v)
Multiply this Vector3f component-wise by another Vector3fc.
|
Vector3f |
mul(Vector3fc v,
Vector3f dest)
Multiply this Vector3f component-wise by another Vector3f and store the result in
dest. |
Vector3f |
mulDirection(Matrix4dc mat)
Multiply the given 4x4 matrix
mat with this. |
Vector3f |
mulDirection(Matrix4dc mat,
Vector3f dest)
Multiply the given 4x4 matrix
mat with this and store the
result in dest. |
Vector3f |
mulDirection(Matrix4fc mat)
Multiply the given 4x4 matrix
mat with this. |
Vector3f |
mulDirection(Matrix4fc mat,
Vector3f dest)
Multiply the given 4x4 matrix
mat with this and store the
result in dest. |
Vector3f |
mulDirection(Matrix4x3fc mat)
Multiply the given 4x3 matrix
mat with this. |
Vector3f |
mulDirection(Matrix4x3fc mat,
Vector3f dest)
Multiply the given 4x3 matrix
mat with this and store the
result in dest. |
Vector3f |
mulPosition(Matrix4fc mat)
Multiply the given 4x4 matrix
mat with this. |
Vector3f |
mulPosition(Matrix4fc mat,
Vector3f dest)
Multiply the given 4x4 matrix
mat with this and store the
result in dest. |
Vector3f |
mulPosition(Matrix4x3fc mat)
Multiply the given 4x3 matrix
mat with this. |
Vector3f |
mulPosition(Matrix4x3fc mat,
Vector3f dest)
Multiply the given 4x3 matrix
mat with this and store the
result in dest. |
float |
mulPositionW(Matrix4fc mat)
Multiply the given 4x4 matrix
mat with this and return the w component
of the resulting 4D vector. |
float |
mulPositionW(Matrix4fc mat,
Vector3f dest)
Multiply the given 4x4 matrix
mat with this, store the
result in dest and return the w component of the resulting 4D vector. |
Vector3f |
mulProject(Matrix4fc mat)
Multiply the given matrix
mat with this Vector3f, perform perspective division. |
Vector3f |
mulProject(Matrix4fc mat,
Vector3f dest)
Multiply the given matrix
mat with this Vector3f, perform perspective division
and store the result in dest. |
Vector3f |
mulTranspose(Matrix3fc mat)
Multiply the transpose of the given matrix with this Vector3f store the result in
this. |
Vector3f |
mulTranspose(Matrix3fc mat,
Vector3f dest)
Multiply the transpose of the given matrix with this Vector3f and store the result in
dest. |
Vector3f |
mulTransposeDirection(Matrix4fc mat)
Multiply the transpose of the given 4x4 matrix
mat with this. |
Vector3f |
mulTransposeDirection(Matrix4fc mat,
Vector3f dest)
Multiply the transpose of the given 4x4 matrix
mat with this and store the
result in dest. |
Vector3f |
mulTransposePosition(Matrix4fc mat)
Multiply the transpose of the given 4x4 matrix
mat with this. |
Vector3f |
mulTransposePosition(Matrix4fc mat,
Vector3f dest)
Multiply the transpose of the given 4x4 matrix
mat with this and store the
result in dest. |
Vector3f |
negate()
Negate this vector.
|
Vector3f |
negate(Vector3f dest)
Negate this vector and store the result in
dest. |
Vector3f |
normalize()
Normalize this vector.
|
Vector3f |
normalize(float length)
Scale this vector to have the given length.
|
Vector3f |
normalize(float length,
Vector3f dest)
Scale this vector to have the given length and store the result in
dest. |
Vector3f |
normalize(Vector3f dest)
Normalize this vector and store the result in
dest. |
Vector3f |
orthogonalize(Vector3fc v)
Transform
this vector so that it is orthogonal to the given vector v and normalize the result. |
Vector3f |
orthogonalize(Vector3fc v,
Vector3f dest)
Transform
this vector so that it is orthogonal to the given vector v, normalize the result and store it into dest. |
Vector3f |
orthogonalizeUnit(Vector3fc v)
Transform
this vector so that it is orthogonal to the given unit vector v and normalize the result. |
Vector3f |
orthogonalizeUnit(Vector3fc v,
Vector3f dest)
Transform
this vector so that it is orthogonal to the given unit vector v, normalize the result and store it into dest. |
void |
readExternal(ObjectInput in) |
Vector3f |
reflect(float x,
float y,
float z)
Reflect this vector about the given normal vector.
|
Vector3f |
reflect(float x,
float y,
float z,
Vector3f dest)
Reflect this vector about the given normal vector and store the result in
dest. |
Vector3f |
reflect(Vector3fc normal)
Reflect this vector about the given
normal vector. |
Vector3f |
reflect(Vector3fc normal,
Vector3f dest)
Reflect this vector about the given
normal vector and store the result in dest. |
Vector3f |
rotate(Quaternionfc quat)
Rotate this vector by the given quaternion
quat and store the result in this. |
Vector3f |
rotate(Quaternionfc quat,
Vector3f dest)
Rotate this vector by the given quaternion
quat and store the result in dest. |
Vector3f |
rotateAxis(float angle,
float x,
float y,
float z)
Rotate this vector the specified radians around the given rotation axis.
|
Vector3f |
rotateAxis(float angle,
float aX,
float aY,
float aZ,
Vector3f dest)
Rotate this vector the specified radians around the given rotation axis and store the result
into
dest. |
Vector3f |
rotateX(float angle)
Rotate this vector the specified radians around the X axis.
|
Vector3f |
rotateX(float angle,
Vector3f dest)
Rotate this vector the specified radians around the X axis and store the result
into
dest. |
Vector3f |
rotateY(float angle)
Rotate this vector the specified radians around the Y axis.
|
Vector3f |
rotateY(float angle,
Vector3f dest)
Rotate this vector the specified radians around the Y axis and store the result
into
dest. |
Vector3f |
rotateZ(float angle)
Rotate this vector the specified radians around the Z axis.
|
Vector3f |
rotateZ(float angle,
Vector3f dest)
Rotate this vector the specified radians around the Z axis and store the result
into
dest. |
Quaternionf |
rotationTo(float toDirX,
float toDirY,
float toDirZ,
Quaternionf dest)
Compute the quaternion representing a rotation of
this vector to point along (toDirX, toDirY, toDirZ)
and store the result in dest. |
Quaternionf |
rotationTo(Vector3fc toDir,
Quaternionf dest)
Compute the quaternion representing a rotation of
this vector to point along toDir
and store the result in dest. |
Vector3f |
round()
Set each component of this vector to the closest float that is equal to
a mathematical integer, with ties rounding to positive infinity.
|
Vector3f |
round(Vector3f dest)
Compute for each component of this vector the closest float that is equal to
a mathematical integer, with ties rounding to positive infinity and store
the result in
dest. |
Vector3f |
set(ByteBuffer buffer)
Read this vector from the supplied
ByteBuffer at the current
buffer position. |
Vector3f |
set(float d)
Set the x, y, and z components to the supplied value.
|
Vector3f |
set(FloatBuffer buffer)
Read this vector from the supplied
FloatBuffer at the current
buffer position. |
Vector3f |
set(float x,
float y,
float z)
Set the x, y and z components to the supplied values.
|
Vector3f |
set(int index,
ByteBuffer buffer)
Read this vector from the supplied
ByteBuffer starting at the specified
absolute buffer position/index. |
Vector3f |
set(int index,
FloatBuffer buffer)
Read this vector from the supplied
FloatBuffer starting at the specified
absolute buffer position/index. |
Vector3f |
set(Vector2fc v,
float z)
Set the first two components from the given
v
and the z component from the given z |
Vector3f |
set(Vector2ic v,
float z)
Set the first two components from the given
v
and the z component from the given z |
Vector3f |
set(Vector3dc v)
Set the x, y and z components to match the supplied vector.
|
Vector3f |
set(Vector3fc v)
Set the x, y and z components to match the supplied vector.
|
Vector3f |
set(Vector3ic v)
Set the x, y and z components to match the supplied vector.
|
Vector3f |
setComponent(int component,
float value)
Set the value of the specified component of this vector.
|
Vector3f |
smoothStep(Vector3fc v,
float t,
Vector3f dest)
Compute a smooth-step (i.e.
|
Vector3f |
sub(float x,
float y,
float z)
Decrement the components of this vector by the given values.
|
Vector3f |
sub(float x,
float y,
float z,
Vector3f dest)
Decrement the components of this vector by the given values and store the result in
dest. |
Vector3f |
sub(Vector3fc v)
Subtract the supplied vector from this one and store the result in
this. |
Vector3f |
sub(Vector3fc v,
Vector3f dest)
Subtract the supplied vector from this one and store the result in
dest. |
String |
toString()
Return a string representation of this vector.
|
String |
toString(NumberFormat formatter)
Return a string representation of this vector by formatting the vector components with the given
NumberFormat. |
void |
writeExternal(ObjectOutput out) |
float |
x() |
float |
y() |
float |
z() |
Vector3f |
zero()
Set all components to zero.
|
public float x
public float y
public float z
public Vector3f()
Vector3f of (0, 0, 0).public Vector3f(float d)
Vector3f and initialize all three components with the given value.d - the value of all three componentspublic Vector3f(float x,
float y,
float z)
Vector3f with the given component values.x - the value of xy - the value of yz - the value of zpublic Vector3f(Vector3fc v)
Vector3f with the same values as v.v - the Vector3fc to copy the values frompublic Vector3f(Vector3ic v)
Vector3f with the same values as v.v - the Vector3ic to copy the values frompublic Vector3f(Vector2fc v, float z)
v - the Vector2fc to copy the values fromz - the z componentpublic Vector3f(Vector2ic v, float z)
v - the Vector2ic to copy the values fromz - the z componentpublic Vector3f(ByteBuffer buffer)
Vector3f and read this vector from the supplied ByteBuffer
at the current buffer position.
This method will not increment the position of the given ByteBuffer.
In order to specify the offset into the ByteBuffer at which
the vector is read, use Vector3f(int, ByteBuffer), taking
the absolute position as parameter.
buffer - values will be read in x, y, z orderVector3f(int, ByteBuffer)public Vector3f(int index,
ByteBuffer buffer)
Vector3f and read this vector from the supplied ByteBuffer
starting at the specified absolute buffer position/index.
This method will not increment the position of the given ByteBuffer.
index - the absolute position into the ByteBufferbuffer - values will be read in x, y, z orderpublic Vector3f(FloatBuffer buffer)
Vector3f and read this vector from the supplied FloatBuffer
at the current buffer position.
This method will not increment the position of the given FloatBuffer.
In order to specify the offset into the FloatBuffer at which
the vector is read, use Vector3f(int, FloatBuffer), taking
the absolute position as parameter.
buffer - values will be read in x, y, z orderVector3f(int, FloatBuffer)public Vector3f(int index,
FloatBuffer buffer)
Vector3f and read this vector from the supplied FloatBuffer
starting at the specified absolute buffer position/index.
This method will not increment the position of the given FloatBuffer.
index - the absolute position into the FloatBufferbuffer - values will be read in x, y, z orderpublic Vector3f set(Vector3fc v)
v - contains the values of x, y and z to setpublic Vector3f set(Vector3dc v)
Note that due to the given vector v storing the components in double-precision,
there is the possibility to lose precision.
v - contains the values of x, y and z to setpublic Vector3f set(Vector3ic v)
v - contains the values of x, y and z to setpublic Vector3f set(Vector2fc v, float z)
v
and the z component from the given zv - the Vector2fc to copy the values fromz - the z componentpublic Vector3f set(Vector2ic v, float z)
v
and the z component from the given zv - the Vector2ic to copy the values fromz - the z componentpublic Vector3f set(float d)
d - the value of all three componentspublic Vector3f set(float x, float y, float z)
x - the x componenty - the y componentz - the z componentpublic Vector3f set(ByteBuffer buffer)
ByteBuffer at the current
buffer position.
This method will not increment the position of the given ByteBuffer.
In order to specify the offset into the ByteBuffer at which
the vector is read, use set(int, ByteBuffer), taking
the absolute position as parameter.
buffer - values will be read in x, y, z orderset(int, ByteBuffer)public Vector3f set(int index, ByteBuffer buffer)
ByteBuffer starting at the specified
absolute buffer position/index.
This method will not increment the position of the given ByteBuffer.
index - the absolute position into the ByteBufferbuffer - values will be read in x, y, z orderpublic Vector3f set(FloatBuffer buffer)
FloatBuffer at the current
buffer position.
This method will not increment the position of the given FloatBuffer.
In order to specify the offset into the FloatBuffer at which
the vector is read, use set(int, FloatBuffer), taking
the absolute position as parameter.
buffer - values will be read in x, y, z orderset(int, FloatBuffer)public Vector3f set(int index, FloatBuffer buffer)
FloatBuffer starting at the specified
absolute buffer position/index.
This method will not increment the position of the given FloatBuffer.
index - the absolute position into the FloatBufferbuffer - values will be read in x, y, z orderpublic Vector3f setComponent(int component, float value) throws IllegalArgumentException
component - the component whose value to set, within [0..2]value - the value to setIllegalArgumentException - if component is not within [0..2]public FloatBuffer get(FloatBuffer buffer)
Vector3fcFloatBuffer at the current
buffer position.
This method will not increment the position of the given FloatBuffer.
In order to specify the offset into the FloatBuffer at which
the vector is stored, use Vector3fc.get(int, FloatBuffer), taking
the absolute position as parameter.
get in interface Vector3fcbuffer - will receive the values of this vector in x, y, z orderVector3fc.get(int, FloatBuffer),
Vector3fc.get(int, FloatBuffer)public FloatBuffer get(int index, FloatBuffer buffer)
Vector3fcFloatBuffer starting at the specified
absolute buffer position/index.
This method will not increment the position of the given FloatBuffer.
public ByteBuffer get(ByteBuffer buffer)
Vector3fcByteBuffer at the current
buffer position.
This method will not increment the position of the given ByteBuffer.
In order to specify the offset into the ByteBuffer at which
the vector is stored, use Vector3fc.get(int, ByteBuffer), taking
the absolute position as parameter.
get in interface Vector3fcbuffer - will receive the values of this vector in x, y, z orderVector3fc.get(int, ByteBuffer),
Vector3fc.get(int, ByteBuffer)public ByteBuffer get(int index, ByteBuffer buffer)
Vector3fcByteBuffer starting at the specified
absolute buffer position/index.
This method will not increment the position of the given ByteBuffer.
public Vector3f sub(Vector3fc v)
this.v - the vector to subtractpublic Vector3f sub(Vector3fc v, Vector3f dest)
Vector3fcdest.public Vector3f sub(float x, float y, float z)
x - the x component to subtracty - the y component to subtractz - the z component to subtractpublic Vector3f sub(float x, float y, float z, Vector3f dest)
Vector3fcdest.public Vector3f add(Vector3fc v)
v - the vector to addpublic Vector3f add(Vector3fc v, Vector3f dest)
Vector3fcdest.public Vector3f add(float x, float y, float z)
x - the x component to addy - the y component to addz - the z component to addpublic Vector3f add(float x, float y, float z, Vector3f dest)
Vector3fcdest.public Vector3f fma(Vector3fc a, Vector3fc b)
a * b to this vector.a - the first multiplicandb - the second multiplicandpublic Vector3f fma(float a, Vector3fc b)
a * b to this vector.a - the first multiplicandb - the second multiplicandpublic Vector3f fma(Vector3fc a, Vector3fc b, Vector3f dest)
Vector3fca * b to this vector
and store the result in dest.public Vector3f fma(float a, Vector3fc b, Vector3f dest)
Vector3fca * b to this vector
and store the result in dest.public Vector3f mul(Vector3fc v)
v - the vector to multiply bypublic Vector3f mul(Vector3fc v, Vector3f dest)
Vector3fcdest.public Vector3f div(Vector3fc v)
v - the vector to divide bypublic Vector3f div(Vector3fc v, Vector3f dest)
Vector3fcdest.public Vector3f mulProject(Matrix4fc mat, Vector3f dest)
Vector3fcmat with this Vector3f, perform perspective division
and store the result in dest.
This method uses w=1.0 as the fourth vector component.
mulProject in interface Vector3fcmat - the matrix to multiply this vector bydest - will hold the resultpublic Vector3f mulProject(Matrix4fc mat)
mat with this Vector3f, perform perspective division.
This method uses w=1.0 as the fourth vector component.
mat - the matrix to multiply this vector bypublic Vector3f mul(Matrix3fc mat)
this.mat - the matrixpublic Vector3f mul(Matrix3fc mat, Vector3f dest)
Vector3fcdest.public Vector3f mul(Matrix3dc mat)
this.mat - the matrixpublic Vector3f mul(Matrix3dc mat, Vector3f dest)
Vector3fcdest.public Vector3f mul(Matrix3x2fc mat)
this.mat - the matrixpublic Vector3f mul(Matrix3x2fc mat, Vector3f dest)
Vector3fcmat with this by assuming a
third row in the matrix of (0, 0, 1) and store the result in dest.public Vector3f mulTranspose(Matrix3fc mat)
this.mat - the matrixpublic Vector3f mulTranspose(Matrix3fc mat, Vector3f dest)
Vector3fcdest.mulTranspose in interface Vector3fcmat - the matrixdest - will hold the resultpublic Vector3f mulPosition(Matrix4fc mat)
mat with this.
This method assumes the w component of this to be 1.0.
mat - the matrix to multiply this vector bypublic Vector3f mulPosition(Matrix4x3fc mat)
mat with this.
This method assumes the w component of this to be 1.0.
mat - the matrix to multiply this vector bypublic Vector3f mulPosition(Matrix4fc mat, Vector3f dest)
Vector3fcmat with this and store the
result in dest.
This method assumes the w component of this to be 1.0.
mulPosition in interface Vector3fcmat - the matrix to multiply this vector bydest - will hold the resultpublic Vector3f mulPosition(Matrix4x3fc mat, Vector3f dest)
Vector3fcmat with this and store the
result in dest.
This method assumes the w component of this to be 1.0.
mulPosition in interface Vector3fcmat - the matrix to multiply this vector bydest - will hold the resultpublic Vector3f mulTransposePosition(Matrix4fc mat)
mat with this.
This method assumes the w component of this to be 1.0.
mat - the matrix whose transpose to multiply this vector bypublic Vector3f mulTransposePosition(Matrix4fc mat, Vector3f dest)
Vector3fcmat with this and store the
result in dest.
This method assumes the w component of this to be 1.0.
mulTransposePosition in interface Vector3fcmat - the matrix whose transpose to multiply this vector bydest - will hold the resultpublic float mulPositionW(Matrix4fc mat)
mat with this and return the w component
of the resulting 4D vector.
This method assumes the w component of this to be 1.0.
mat - the matrix to multiply this vector bypublic float mulPositionW(Matrix4fc mat, Vector3f dest)
Vector3fcmat with this, store the
result in dest and return the w component of the resulting 4D vector.
This method assumes the w component of this to be 1.0.
mulPositionW in interface Vector3fcmat - the matrix to multiply this vector bydest - will hold the (x, y, z) components of the resulting vectorpublic Vector3f mulDirection(Matrix4dc mat)
mat with this.
This method assumes the w component of this to be 0.0.
mat - the matrix to multiply this vector bypublic Vector3f mulDirection(Matrix4fc mat)
mat with this.
This method assumes the w component of this to be 0.0.
mat - the matrix to multiply this vector bypublic Vector3f mulDirection(Matrix4x3fc mat)
mat with this.
This method assumes the w component of this to be 0.0.
mat - the matrix to multiply this vector bypublic Vector3f mulDirection(Matrix4dc mat, Vector3f dest)
Vector3fcmat with this and store the
result in dest.
This method assumes the w component of this to be 0.0.
mulDirection in interface Vector3fcmat - the matrix to multiply this vector bydest - will hold the resultpublic Vector3f mulDirection(Matrix4fc mat, Vector3f dest)
Vector3fcmat with this and store the
result in dest.
This method assumes the w component of this to be 0.0.
mulDirection in interface Vector3fcmat - the matrix to multiply this vector bydest - will hold the resultpublic Vector3f mulDirection(Matrix4x3fc mat, Vector3f dest)
Vector3fcmat with this and store the
result in dest.
This method assumes the w component of this to be 0.0.
mulDirection in interface Vector3fcmat - the matrix to multiply this vector bydest - will hold the resultpublic Vector3f mulTransposeDirection(Matrix4fc mat)
mat with this.
This method assumes the w component of this to be 0.0.
mat - the matrix whose transpose to multiply this vector bypublic Vector3f mulTransposeDirection(Matrix4fc mat, Vector3f dest)
Vector3fcmat with this and store the
result in dest.
This method assumes the w component of this to be 0.0.
mulTransposeDirection in interface Vector3fcmat - the matrix whose transpose to multiply this vector bydest - will hold the resultpublic Vector3f mul(float scalar)
Vector3f by the given scalar
value.scalar - the scalar to multiply this vector bypublic Vector3f mul(float scalar, Vector3f dest)
Vector3fcVector3f by the given scalar
value and store the result in dest.public Vector3f mul(float x, float y, float z)
this.x - the x component to multiply this vector byy - the y component to multiply this vector byz - the z component to multiply this vector bypublic Vector3f mul(float x, float y, float z, Vector3f dest)
Vector3fcdest.public Vector3f div(float scalar)
Vector3f by the given scalar
value.scalar - the scalar to divide bypublic Vector3f div(float scalar, Vector3f dest)
Vector3fcVector3f by the given scalar
value and store the result in dest.public Vector3f div(float x, float y, float z)
this.x - the x component to divide this vector byy - the y component to divide this vector byz - the z component to divide this vector bypublic Vector3f div(float x, float y, float z, Vector3f dest)
Vector3fcdest.public Vector3f rotate(Quaternionfc quat)
quat and store the result in this.quat - the quaternion to rotate this vectorQuaternionfc.transform(Vector3f)public Vector3f rotate(Quaternionfc quat, Vector3f dest)
Vector3fcquat and store the result in dest.rotate in interface Vector3fcquat - the quaternion to rotate this vectordest - will hold the resultQuaternionfc.transform(Vector3f)public Quaternionf rotationTo(Vector3fc toDir, Quaternionf dest)
Vector3fcthis vector to point along toDir
and store the result in dest.
Because there can be multiple possible rotations, this method chooses the one with the shortest arc.
rotationTo in interface Vector3fctoDir - the destination directiondest - will hold the resultQuaternionf.rotationTo(Vector3fc, Vector3fc)public Quaternionf rotationTo(float toDirX, float toDirY, float toDirZ, Quaternionf dest)
Vector3fcthis vector to point along (toDirX, toDirY, toDirZ)
and store the result in dest.
Because there can be multiple possible rotations, this method chooses the one with the shortest arc.
rotationTo in interface Vector3fctoDirX - the x coordinate of the destination directiontoDirY - the y coordinate of the destination directiontoDirZ - the z coordinate of the destination directiondest - will hold the resultQuaternionf.rotationTo(float, float, float, float, float, float)public Vector3f rotateAxis(float angle, float x, float y, float z)
angle - the angle in radiansx - the x component of the rotation axisy - the y component of the rotation axisz - the z component of the rotation axispublic Vector3f rotateAxis(float angle, float aX, float aY, float aZ, Vector3f dest)
Vector3fcdest.rotateAxis in interface Vector3fcangle - the angle in radiansaX - the x component of the rotation axisaY - the y component of the rotation axisaZ - the z component of the rotation axisdest - will hold the resultpublic Vector3f rotateX(float angle)
angle - the angle in radianspublic Vector3f rotateX(float angle, Vector3f dest)
Vector3fcdest.public Vector3f rotateY(float angle)
angle - the angle in radianspublic Vector3f rotateY(float angle, Vector3f dest)
Vector3fcdest.public Vector3f rotateZ(float angle)
angle - the angle in radianspublic Vector3f rotateZ(float angle, Vector3f dest)
Vector3fcdest.public float lengthSquared()
Vector3fclengthSquared in interface Vector3fcpublic static float lengthSquared(float x,
float y,
float z)
x - The vector's x componenty - The vector's y componentz - The vector's z componentpublic float length()
Vector3fcpublic static float length(float x,
float y,
float z)
x - The vector's x componenty - The vector's y componentz - The vector's z componentpublic Vector3f normalize()
public Vector3f normalize(Vector3f dest)
Vector3fcdest.public Vector3f normalize(float length)
length - the desired lengthpublic Vector3f normalize(float length, Vector3f dest)
Vector3fcdest.public Vector3f cross(Vector3fc v)
v.v - the other vectorpublic Vector3f cross(float x, float y, float z)
(x, y, z).x - the x component of the other vectory - the y component of the other vectorz - the z component of the other vectorpublic Vector3f cross(Vector3fc v, Vector3f dest)
Vector3fcv and store the result in dest.public Vector3f cross(float x, float y, float z, Vector3f dest)
Vector3fc(x, y, z) and store the result in dest.public float distance(Vector3fc v)
Vector3fcv.public float distance(float x,
float y,
float z)
Vector3fcthis vector and (x, y, z).public float distanceSquared(Vector3fc v)
Vector3fcv.distanceSquared in interface Vector3fcv - the other vectorpublic float distanceSquared(float x,
float y,
float z)
Vector3fcthis vector and (x, y, z).distanceSquared in interface Vector3fcx - the x component of the other vectory - the y component of the other vectorz - the z component of the other vectorpublic static float distance(float x1,
float y1,
float z1,
float x2,
float y2,
float z2)
(x1, y1, z1) and (x2, y2, z2).x1 - the x component of the first vectory1 - the y component of the first vectorz1 - the z component of the first vectorx2 - the x component of the second vectory2 - the y component of the second vectorz2 - the z component of the second vectorpublic static float distanceSquared(float x1,
float y1,
float z1,
float x2,
float y2,
float z2)
(x1, y1, z1) and (x2, y2, z2).x1 - the x component of the first vectory1 - the y component of the first vectorz1 - the z component of the first vectorx2 - the x component of the second vectory2 - the y component of the second vectorz2 - the z component of the second vectorpublic float dot(Vector3fc v)
Vector3fcpublic float dot(float x,
float y,
float z)
Vector3fc(x, y, z).public float angleCos(Vector3fc v)
Vector3fcangleCos in interface Vector3fcv - the other vectorVector3fc.angle(Vector3fc)public float angle(Vector3fc v)
Vector3fcangle in interface Vector3fcv - the other vectorVector3fc.angleCos(Vector3fc)public float angleSigned(Vector3fc v, Vector3fc n)
Vector3fcn.angleSigned in interface Vector3fcv - the other vectorn - the plane's normal vectorVector3fc.angleCos(Vector3fc)public float angleSigned(float x,
float y,
float z,
float nx,
float ny,
float nz)
Vector3fc(nx, ny, nz).angleSigned in interface Vector3fcx - the x coordinate of the other vectory - the y coordinate of the other vectorz - the z coordinate of the other vectornx - the x coordinate of the plane's normal vectorny - the y coordinate of the plane's normal vectornz - the z coordinate of the plane's normal vectorpublic Vector3f min(Vector3fc v)
v - the other vectorpublic Vector3f min(Vector3fc v, Vector3f dest)
Vector3fcdest to be the component-wise minimum of this and the other vector.public Vector3f max(Vector3fc v)
v - the other vectorpublic Vector3f max(Vector3fc v, Vector3f dest)
Vector3fcdest to be the component-wise maximum of this and the other vector.public Vector3f zero()
public String toString()
This method creates a new DecimalFormat on every invocation with the format string "0.000E0;-".
public String toString(NumberFormat formatter)
NumberFormat.formatter - the NumberFormat used to format the vector components withpublic void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface ExternalizableIOExceptionpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface ExternalizableIOExceptionClassNotFoundExceptionpublic Vector3f negate()
public Vector3f negate(Vector3f dest)
Vector3fcdest.public Vector3f absolute()
this vector's components to their respective absolute values.public Vector3f absolute(Vector3f dest)
Vector3fcthis and store the result in dest.public boolean equals(Vector3fc v, float delta)
Vector3fcthis vector with the given vector using the given delta
and return whether all of them are equal within a maximum difference of delta.
Please note that this method is not used by any data structure such as ArrayList HashSet or HashMap
and their operations, such as ArrayList.contains(Object) or HashSet.remove(Object), since those
data structures only use the Object.equals(Object) and Object.hashCode() methods.
public boolean equals(float x,
float y,
float z)
Vector3fcthis vector with the given (x, y, z)
and return whether all of them are equal.public Vector3f reflect(Vector3fc normal)
normal vector.normal - the vector to reflect aboutpublic Vector3f reflect(float x, float y, float z)
x - the x component of the normaly - the y component of the normalz - the z component of the normalpublic Vector3f reflect(Vector3fc normal, Vector3f dest)
Vector3fcnormal vector and store the result in dest.public Vector3f reflect(float x, float y, float z, Vector3f dest)
Vector3fcdest.public Vector3f half(Vector3fc other)
other - the other vectorpublic Vector3f half(float x, float y, float z)
(x, y, z).x - the x component of the other vectory - the y component of the other vectorz - the z component of the other vectorpublic Vector3f half(Vector3fc other, Vector3f dest)
Vector3fcdest.public Vector3f half(float x, float y, float z, Vector3f dest)
Vector3fc(x, y, z)
and store the result in dest.public Vector3f smoothStep(Vector3fc v, float t, Vector3f dest)
Vector3fcthis vector and the given vector v and
store the result in dest.smoothStep in interface Vector3fcv - the other vectort - the interpolation factor, within [0..1]dest - will hold the resultpublic Vector3f hermite(Vector3fc t0, Vector3fc v1, Vector3fc t1, float t, Vector3f dest)
Vector3fcthis vector with its
associated tangent t0 and the given vector v
with its tangent t1 and store the result in
dest.public Vector3f lerp(Vector3fc other, float t)
this and other using the given interpolation factor t
and store the result in this.
If t is 0.0 then the result is this. If the interpolation factor is 1.0
then the result is other.
other - the other vectort - the interpolation factor between 0.0 and 1.0public Vector3f lerp(Vector3fc other, float t, Vector3f dest)
Vector3fcthis and other using the given interpolation factor t
and store the result in dest.
If t is 0.0 then the result is this. If the interpolation factor is 1.0
then the result is other.
public float get(int component)
throws IllegalArgumentException
Vector3fcget in interface Vector3fccomponent - the component, within [0..2]IllegalArgumentException - if component is not within [0..2]public int maxComponent()
Vector3fcmaxComponent in interface Vector3fc[0..2]public int minComponent()
Vector3fcminComponent in interface Vector3fc[0..2]public Vector3f orthogonalize(Vector3fc v, Vector3f dest)
Vector3fcthis vector so that it is orthogonal to the given vector v, normalize the result and store it into dest.
Reference: Gram–Schmidt process
orthogonalize in interface Vector3fcv - the reference vector which the result should be orthogonal todest - will hold the resultpublic Vector3f orthogonalize(Vector3fc v)
this vector so that it is orthogonal to the given vector v and normalize the result.
Reference: Gram–Schmidt process
v - the reference vector which the result should be orthogonal topublic Vector3f orthogonalizeUnit(Vector3fc v, Vector3f dest)
Vector3fcthis vector so that it is orthogonal to the given unit vector v, normalize the result and store it into dest.
The vector v is assumed to be a unit vector.
Reference: Gram–Schmidt process
orthogonalizeUnit in interface Vector3fcv - the reference unit vector which the result should be orthogonal todest - will hold the resultpublic Vector3f orthogonalizeUnit(Vector3fc v)
this vector so that it is orthogonal to the given unit vector v and normalize the result.
The vector v is assumed to be a unit vector.
Reference: Gram–Schmidt process
v - the reference unit vector which the result should be orthogonal topublic Vector3f floor()
float value that is less than or equal to that
component and is equal to a mathematical integer.public Vector3f floor(Vector3f dest)
Vector3fcfloat value that is less than or equal to that
component and is equal to a mathematical integer and store the result in
dest.public Vector3f ceil()
float value that is greater than or equal to that
component and is equal to a mathematical integer.public Vector3f ceil(Vector3f dest)
Vector3fcfloat value that is greater than or equal to that
component and is equal to a mathematical integer and store the result in
dest.public Vector3f round()
public Vector3f round(Vector3f dest)
Vector3fcdest.public boolean isFinite()
Vector3fcCopyright © 2015–2019 JOML. All rights reserved.