public class Vector4f extends Object implements Externalizable
| Modifier and Type | Field and Description |
|---|---|
float |
w
The w component of the vector.
|
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 |
|---|
Vector4f()
Create a new
Vector4f of (0, 0, 0, 1). |
Vector4f(ByteBuffer buffer)
Create a new
Vector4f and read this vector from the supplied ByteBuffer
at the current buffer position. |
Vector4f(float d)
Create a new
Vector4f and initialize all four components with the given value. |
Vector4f(FloatBuffer buffer)
Create a new
Vector4f and read this vector from the supplied FloatBuffer
at the current buffer position. |
Vector4f(float x,
float y,
float z,
float w)
Create a new
Vector4f with the given component values. |
Vector4f(int index,
ByteBuffer buffer)
Create a new
Vector4f and read this vector from the supplied ByteBuffer
starting at the specified absolute buffer position/index. |
Vector4f(int index,
FloatBuffer buffer)
Create a new
Vector4f and read this vector from the supplied FloatBuffer
starting at the specified absolute buffer position/index. |
Vector4f(Vector3f v,
float w)
|
Vector4f(Vector4f v)
Create a new
Vector4f with the same values as v. |
| Modifier and Type | Method and Description |
|---|---|
Vector4f |
add(float x,
float y,
float z,
float w)
Increment the components of this vector by the given values.
|
Vector4f |
add(float x,
float y,
float z,
float w,
Vector4f dest)
Increment the components of this vector by the given values and store the result in
dest. |
Vector4f |
add(Vector4f v)
Add the supplied vector to this one.
|
Vector4f |
add(Vector4f v,
Vector4f dest)
Add the supplied vector to this one and store the result in
dest. |
float |
angle(Vector4f v)
Return the angle between this vector and the supplied vector.
|
float |
angleCos(Vector4f v)
Return the cosine of the angle between this vector and the supplied vector.
|
float |
distance(float x,
float y,
float z,
float w)
Return the distance between
this vector and (x, y, z, w). |
float |
distance(Vector4f v)
Return the distance between
this vector and v. |
Vector4f |
div(float scalar)
Divide all components of this
Vector4f by the given scalar
value. |
Vector4f |
div(float x,
float y,
float z,
float w)
Divide the components of this Vector4f by the given scalar values and store the result in
this. |
Vector4f |
div(float x,
float y,
float z,
float w,
Vector4f dest)
Divide the components of this Vector4f by the given scalar values and store the result in
dest. |
Vector4f |
div(float scalar,
Vector4f dest)
Divide all components of this
Vector4f by the given scalar
value and store the result in dest. |
Vector4f |
div(Vector4f v)
Divide this Vector4f component-wise by another Vector4f.
|
Vector4f |
div(Vector4f v,
Vector4f dest)
Divide this Vector4f component-wise by another Vector4f and store the result in
dest. |
float |
dot(float x,
float y,
float z,
float w)
Compute the dot product (inner product) of this vector and (x, y, z, w).
|
float |
dot(Vector4f v)
Compute the dot product (inner product) of this vector and
v
. |
boolean |
equals(Object obj) |
Vector4f |
fma(float a,
Vector4f b)
Add the component-wise multiplication of
a * b to this vector. |
Vector4f |
fma(float a,
Vector4f b,
Vector4f dest)
Add the component-wise multiplication of
a * b to this vector
and store the result in dest. |
Vector4f |
fma(Vector4f a,
Vector4f b)
Add the component-wise multiplication of
a * b to this vector. |
Vector4f |
fma(Vector4f a,
Vector4f b,
Vector4f 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. |
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. |
int |
hashCode() |
Vector4f |
hermite(Vector4f t0,
Vector4f v1,
Vector4f t1,
float t,
Vector4f dest)
Compute a hermite interpolation between
this vector and its
associated tangent t0 and the given vector v
with its tangent t1 and store the result in
dest. |
float |
length()
Return the length of this vector.
|
float |
lengthSquared()
Return the length squared of this vector.
|
Vector4f |
lerp(Vector4f other,
float t)
Linearly interpolate
this and other using the given interpolation factor t
and store the result in this. |
Vector4f |
lerp(Vector4f other,
float t,
Vector4f dest)
Linearly interpolate
this and other using the given interpolation factor t
and store the result in dest. |
Vector4f |
max(Vector4f v)
Set the components of this vector to be the component-wise maximum of
this and the other vector.
|
Vector4f |
min(Vector4f v)
Set the components of this vector to be the component-wise minimum of
this and the other vector.
|
Vector4f |
mul(float scalar)
Multiply all components of this
Vector4f by the given scalar
value. |
Vector4f |
mul(float x,
float y,
float z,
float w)
Multiply the components of this Vector4f by the given scalar values and store the result in
this. |
Vector4f |
mul(float x,
float y,
float z,
float w,
Vector4f dest)
Multiply the components of this Vector4f by the given scalar values and store the result in
dest. |
Vector4f |
mul(float scalar,
Vector4f dest)
Multiply all components of this
Vector4f by the given scalar
value and store the result in dest. |
Vector4f |
mul(Matrix4f mat)
Multiply this Vector4f by the given matrix mat and store the result in
this. |
Vector4f |
mul(Matrix4f mat,
Vector4f dest)
Multiply this Vector4f by the given matrix mat and store the result in
dest. |
Vector4f |
mul(Vector4f v)
Multiply this Vector4f component-wise by another Vector4f.
|
Vector4f |
mul(Vector4f v,
Vector4f dest)
Multiply this Vector4f component-wise by another Vector4f and store the result in
dest. |
Vector4f |
mulProject(Matrix4f mat)
Multiply this Vector4f by the given matrix
mat, perform perspective division. |
Vector4f |
mulProject(Matrix4f mat,
Vector4f dest)
Multiply this Vector4f by the given matrix
mat, perform perspective division
and store the result in dest. |
Vector4f |
negate()
Negate this vector.
|
Vector4f |
negate(Vector4f dest)
Negate this vector and store the result in
dest. |
Vector4f |
normalize()
Normalizes this vector.
|
Vector4f |
normalize(Vector4f dest)
Normalizes this vector and store the result in
dest. |
Vector4f |
normalize3()
Normalize this vector by computing only the norm of (x, y, z).
|
void |
readExternal(ObjectInput in) |
Vector4f |
rotate(Quaternionf quat)
Rotate this vector by the given quaternion
quat and store the result in this. |
Vector4f |
rotate(Quaternionf quat,
Vector4f dest)
Rotate this vector by the given quaternion
quat and store the result in dest. |
Vector4f |
set(ByteBuffer buffer)
Read this vector from the supplied
ByteBuffer at the current
buffer position. |
Vector4f |
set(float d)
Set the x, y, z, and w components to the supplied value.
|
Vector4f |
set(FloatBuffer buffer)
Read this vector from the supplied
FloatBuffer at the current
buffer position. |
Vector4f |
set(float x,
float y,
float z,
float w)
Set the x, y, z, and w components to the supplied values.
|
Vector4f |
set(int index,
ByteBuffer buffer)
Read this vector from the supplied
ByteBuffer starting at the specified
absolute buffer position/index. |
Vector4f |
set(int index,
FloatBuffer buffer)
Read this vector from the supplied
FloatBuffer starting at the specified
absolute buffer position/index. |
Vector4f |
set(Vector3f v,
float w)
Set the first three components of this to the components of
v and the last component to w. |
Vector4f |
set(Vector4f v)
Set this
Vector4f to the values of the given v. |
Vector4f |
smoothStep(Vector4f v,
float t,
Vector4f dest)
Compute a smooth-step (i.e. hermite with zero tangents) interpolation
between
this vector and the given vector v and
store the result in dest. |
Vector4f |
sub(float x,
float y,
float z,
float w)
Subtract (x, y, z, w) from this.
|
Vector4f |
sub(float x,
float y,
float z,
float w,
Vector4f dest)
Subtract (x, y, z, w) from this and store the result in
dest. |
Vector4f |
sub(Vector4f v)
Subtract the supplied vector from this one.
|
Vector4f |
sub(Vector4f v,
Vector4f 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) |
Vector4f |
zero()
Set all components to zero.
|
public float x
public float y
public float z
public float w
public Vector4f()
Vector4f of (0, 0, 0, 1).public Vector4f(Vector4f v)
Vector4f with the same values as v.v - the Vector4f to copy the values frompublic Vector4f(float d)
Vector4f and initialize all four components with the given value.d - the value of all four componentspublic Vector4f(float x,
float y,
float z,
float w)
Vector4f with the given component values.x - the x componenty - the y componentz - the z componentw - the w componentpublic Vector4f(ByteBuffer buffer)
Vector4f 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 Vector4f(int, ByteBuffer), taking
the absolute position as parameter.
buffer - values will be read in x, y, z, w orderVector4f(int, ByteBuffer)public Vector4f(int index,
ByteBuffer buffer)
Vector4f 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, w orderpublic Vector4f(FloatBuffer buffer)
Vector4f 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 Vector4f(int, FloatBuffer), taking
the absolute position as parameter.
buffer - values will be read in x, y, z, w orderVector4f(int, FloatBuffer)public Vector4f(int index,
FloatBuffer buffer)
Vector4f 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, w orderpublic Vector4f set(Vector4f v)
Vector4f to the values of the given v.v - the vector whose values will be copied into thispublic Vector4f set(Vector3f v, float w)
v and the last component to w.v - the Vector3f to copyw - the w componentpublic Vector4f set(float d)
d - the value of all four componentspublic Vector4f set(float x, float y, float z, float w)
x - the x componenty - the y componentz - the z componentw - the w componentpublic Vector4f 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, w orderset(int, ByteBuffer)public Vector4f 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, w orderpublic Vector4f 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, w orderset(int, FloatBuffer)public Vector4f 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, w orderpublic FloatBuffer get(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 stored, use get(int, FloatBuffer), taking
the absolute position as parameter.
buffer - will receive the values of this vector in x, y, z, w orderget(int, FloatBuffer)public FloatBuffer get(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 - will receive the values of this vector in x, y, z, w orderpublic ByteBuffer get(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 stored, use get(int, ByteBuffer), taking
the absolute position as parameter.
buffer - will receive the values of this vector in x, y, z, w orderget(int, ByteBuffer)public ByteBuffer get(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 - will receive the values of this vector in x, y, z, w orderpublic Vector4f sub(Vector4f v)
v - the vector to subtractpublic Vector4f sub(float x, float y, float z, float w)
x - the x component to subtracty - the y component to subtractz - the z component to subtractw - the w component to subtractpublic Vector4f sub(Vector4f v, Vector4f dest)
dest.v - the vector to subtract from thisdest - will hold the resultpublic Vector4f sub(float x, float y, float z, float w, Vector4f dest)
dest.x - the x component to subtracty - the y component to subtractz - the z component to subtractw - the w component to subtractdest - will hold the resultpublic Vector4f add(Vector4f v)
v - the vector to addpublic Vector4f add(Vector4f v, Vector4f dest)
dest.v - the vector to adddest - will hold the resultpublic Vector4f add(float x, float y, float z, float w)
x - the x component to addy - the y component to addz - the z component to addw - the w component to addpublic Vector4f add(float x, float y, float z, float w, Vector4f dest)
dest.x - the x component to addy - the y component to addz - the z component to addw - the w component to adddest - will hold the resultpublic Vector4f fma(Vector4f a, Vector4f b)
a * b to this vector.a - the first multiplicandb - the second multiplicandpublic Vector4f fma(float a, Vector4f b)
a * b to this vector.a - the first multiplicandb - the second multiplicandpublic Vector4f fma(Vector4f a, Vector4f b, Vector4f dest)
a * b to this vector
and store the result in dest.a - the first multiplicandb - the second multiplicanddest - will hold the resultpublic Vector4f fma(float a, Vector4f b, Vector4f dest)
a * b to this vector
and store the result in dest.a - the first multiplicandb - the second multiplicanddest - will hold the resultpublic Vector4f mul(Vector4f v)
v - the other vectorpublic Vector4f mul(Vector4f v, Vector4f dest)
dest.v - the other vectordest - will hold the resultpublic Vector4f div(Vector4f v)
v - the vector to divide bypublic Vector4f div(Vector4f v, Vector4f dest)
dest.v - the vector to divide bydest - will hold the resultpublic Vector4f mul(Matrix4f mat)
this.mat - the matrix to multiply the vector withpublic Vector4f mul(Matrix4f mat, Vector4f dest)
dest.mat - the matrix to multiply the vector withdest - the destination vector to hold the resultpublic Vector4f mulProject(Matrix4f mat, Vector4f dest)
mat, perform perspective division
and store the result in dest.mat - the matrix to multiply this vector bydest - will hold the resultpublic Vector4f mulProject(Matrix4f mat)
mat, perform perspective division.mat - the matrix to multiply this vector bypublic Vector4f mul(float scalar)
Vector4f by the given scalar
value.scalar - the scalar to multiply bypublic Vector4f mul(float scalar, Vector4f dest)
Vector4f by the given scalar
value and store the result in dest.scalar - the scalar to multiply bydest - will hold the resultpublic Vector4f mul(float x, float y, float z, float w)
this.x - the x component to multiply byy - the y component to multiply byz - the z component to multiply byw - the w component to multiply bypublic Vector4f mul(float x, float y, float z, float w, Vector4f dest)
dest.x - the x component to multiply byy - the y component to multiply byz - the z component to multiply byw - the w component to multiply bydest - will hold the resultpublic Vector4f div(float scalar)
Vector4f by the given scalar
value.scalar - the scalar to divide bypublic Vector4f div(float scalar, Vector4f dest)
Vector4f by the given scalar
value and store the result in dest.scalar - the scalar to divide bydest - will hold the resultpublic Vector4f div(float x, float y, float z, float w)
this.x - the x component to divide byy - the y component to divide byz - the z component to divide byw - the w component to divide bypublic Vector4f div(float x, float y, float z, float w, Vector4f dest)
dest.x - the x component to divide byy - the y component to divide byz - the z component to divide byw - the w component to divide bydest - will hold the resultpublic Vector4f rotate(Quaternionf quat)
quat and store the result in this.quat - the quaternion to rotate this vectorQuaternionf.transform(Vector4f)public Vector4f rotate(Quaternionf quat, Vector4f dest)
quat and store the result in dest.quat - the quaternion to rotate this vectordest - will hold the resultQuaternionf.transform(Vector4f)public float lengthSquared()
public float length()
public Vector4f normalize()
public Vector4f normalize(Vector4f dest)
dest.dest - will hold the resultpublic Vector4f normalize3()
public float distance(Vector4f v)
this vector and v.v - the other vectorpublic float distance(float x,
float y,
float z,
float w)
this vector and (x, y, z, w).x - the x component of the other vectory - the y component of the other vectorz - the z component of the other vectorw - the w component of the other vectorpublic float dot(Vector4f v)
v
.v - the other vectorpublic float dot(float x,
float y,
float z,
float w)
x - the x component of the other vectory - the y component of the other vectorz - the z component of the other vectorw - the w component of the other vectorpublic float angleCos(Vector4f v)
Math.cos(angle(v)).v - the other vectorangle(Vector4f)public float angle(Vector4f v)
v - the other vectorangleCos(Vector4f)public Vector4f zero()
public Vector4f negate()
public Vector4f negate(Vector4f dest)
dest.dest - will hold the resultpublic 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 Vector4f min(Vector4f v)
v - the other vectorpublic Vector4f max(Vector4f v)
v - the other vectorpublic Vector4f smoothStep(Vector4f v, float t, Vector4f dest)
this vector and the given vector v and
store the result in dest.v - the other vectort - the interpolation factor, within [0..1]dest - will hold the resultpublic Vector4f hermite(Vector4f t0, Vector4f v1, Vector4f t1, float t, Vector4f dest)
this vector and its
associated tangent t0 and the given vector v
with its tangent t1 and store the result in
dest.t0 - the tangent of this vectorv1 - the other vectort1 - the tangent of the other vectort - the interpolation factor, within [0..1]dest - will hold the resultpublic Vector4f lerp(Vector4f 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 Vector4f lerp(Vector4f other, float t, Vector4f dest)
this 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.
other - the other vectort - the interpolation factor between 0.0 and 1.0dest - will hold the resultCopyright © 2015–2016 JOML. All rights reserved.