public class Vector4f extends Object implements Externalizable, Vector4fc
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(Vector2fc v,
float z,
float w)
|
Vector4f(Vector3fc v,
float w)
|
Vector4f(Vector4fc 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(Vector4fc v)
Add the supplied vector to this one.
|
Vector4f |
add(Vector4fc v,
Vector4f dest)
Add the supplied vector to this one and store the result in
dest . |
float |
angle(Vector4fc v)
Return the angle between this vector and the supplied vector.
|
float |
angleCos(Vector4fc 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(Vector4fc 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(Vector4fc v)
Divide this Vector4f component-wise by another Vector4f.
|
Vector4f |
div(Vector4fc 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(Vector4fc v)
Compute the dot product (inner product) of this vector and
v
. |
boolean |
equals(Object obj) |
Vector4f |
fma(float a,
Vector4fc b)
Add the component-wise multiplication of
a * b to this vector. |
Vector4f |
fma(float a,
Vector4fc b,
Vector4f dest)
Add the component-wise multiplication of
a * b to this vector
and store the result in dest . |
Vector4f |
fma(Vector4fc a,
Vector4fc b)
Add the component-wise multiplication of
a * b to this vector. |
Vector4f |
fma(Vector4fc a,
Vector4fc 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 . |
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. |
int |
hashCode() |
Vector4f |
hermite(Vector4fc t0,
Vector4fc v1,
Vector4fc 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(Vector4fc other,
float t)
Linearly interpolate
this and other using the given interpolation factor t
and store the result in this . |
Vector4f |
lerp(Vector4fc other,
float t,
Vector4f dest)
Linearly interpolate
this and other using the given interpolation factor t
and store the result in dest . |
Vector4f |
max(Vector4fc v)
Set the components of this vector to be the component-wise maximum of
this and the other vector.
|
Vector4f |
min(Vector4fc 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(Matrix4fc mat)
Multiply the given matrix mat with this Vector4f and store the result in
this . |
Vector4f |
mul(Matrix4fc mat,
Vector4f dest)
Multiply the given matrix mat with this Vector4f and store the result in
dest . |
Vector4f |
mul(Matrix4x3fc mat)
Multiply the given matrix mat with this Vector4f and store the result in
this . |
Vector4f |
mul(Matrix4x3fc mat,
Vector4f dest)
Multiply the given matrix mat with this Vector4f and store the result in
dest . |
Vector4f |
mul(Vector4fc v)
Multiply this Vector4f component-wise by another Vector4f.
|
Vector4f |
mul(Vector4fc v,
Vector4f dest)
Multiply this Vector4f component-wise by another Vector4f and store the result in
dest . |
Vector4f |
mulProject(Matrix4fc mat)
Multiply the given matrix
mat with this Vector4f, perform perspective division. |
Vector4f |
mulProject(Matrix4fc mat,
Vector4f dest)
Multiply the given matrix
mat with this Vector4f, 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(Quaternionfc quat)
Rotate this vector by the given quaternion
quat and store the result in this . |
Vector4f |
rotate(Quaternionfc quat,
Vector4f dest)
Rotate this vector by the given quaternion
quat and store the result in dest . |
Vector4f |
rotateAbout(float angle,
float x,
float y,
float z)
Rotate this vector the specified radians about the given rotation axis.
|
Vector4f |
rotateAbout(float angle,
float x,
float y,
float z,
Vector4f dest)
Rotate this vector the specified radians about the given rotation axis and store the result
into
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(Vector2fc v,
float z,
float w)
Sets the first two components of this to the components of given
v
and last two components to the given z , and w . |
Vector4f |
set(Vector3fc v,
float w)
Set the first three components of this to the components of
v and the last component to w . |
Vector4f |
set(Vector4dc v)
Set this
Vector4f to the values of the given v . |
Vector4f |
set(Vector4fc v)
Set this
Vector4f to the values of the given v . |
Vector4f |
setComponent(int component,
float value)
Set the value of the specified component of this vector.
|
Vector4f |
smoothStep(Vector4fc 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(Vector4fc v)
Subtract the supplied vector from this one.
|
Vector4f |
sub(Vector4fc v,
Vector4f dest)
Subtract the supplied vector from this one and store the result in
dest . |
Vector4fc |
toImmutable()
Create a new immutable view of this
Vector4f . |
String |
toString()
Return a string representation of this vector.
|
String |
toString(NumberFormat formatter)
Return a string representation of this quaternion by formatting the vector components with the given
NumberFormat . |
float |
w() |
void |
writeExternal(ObjectOutput out) |
float |
x() |
float |
y() |
float |
z() |
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(Vector4fc v)
Vector4f
with the same values as v
.v
- the Vector4fc
to copy the values frompublic Vector4f(Vector2fc v, float z, float w)
v
- the Vector2fc
z
- the z componentw
- the w componentpublic 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(Vector4fc v)
Vector4f
to the values of the given v
.v
- the vector whose values will be copied into thispublic Vector4f set(Vector4dc v)
Vector4f
to the values of the given v
.
Note that due to the given vector v
storing the components in double-precision,
there is the possibility to lose precision.
v
- the vector whose values will be copied into thispublic Vector4f set(Vector3fc v, float w)
v
and the last component to w
.v
- the Vector3fc
to copyw
- the w componentpublic Vector4f set(Vector2fc v, float z, float w)
v
and last two components to the given z
, and w
.v
- the Vector2fc
z
- the z componentw
- 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 Vector4f setComponent(int component, float value) throws IllegalArgumentException
component
- the component whose value to set, within [0..3]value
- the value to setIllegalArgumentException
- if component
is not within [0..3]public FloatBuffer get(FloatBuffer buffer)
Vector4fc
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 Vector4fc.get(int, FloatBuffer)
, taking
the absolute position as parameter.
get
in interface Vector4fc
buffer
- will receive the values of this vector in x, y, z, w orderVector4fc.get(int, FloatBuffer)
public FloatBuffer get(int index, FloatBuffer buffer)
Vector4fc
FloatBuffer
starting at the specified
absolute buffer position/index.
This method will not increment the position of the given FloatBuffer.
public ByteBuffer get(ByteBuffer buffer)
Vector4fc
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 Vector4fc.get(int, ByteBuffer)
, taking
the absolute position as parameter.
get
in interface Vector4fc
buffer
- will receive the values of this vector in x, y, z, w orderVector4fc.get(int, ByteBuffer)
public ByteBuffer get(int index, ByteBuffer buffer)
Vector4fc
ByteBuffer
starting at the specified
absolute buffer position/index.
This method will not increment the position of the given ByteBuffer.
public Vector4f sub(Vector4fc 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(Vector4fc v, Vector4f dest)
Vector4fc
dest
.public Vector4f sub(float x, float y, float z, float w, Vector4f dest)
Vector4fc
dest
.public Vector4f add(Vector4fc v)
v
- the vector to addpublic Vector4f add(Vector4fc v, Vector4f dest)
Vector4fc
dest
.public 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)
Vector4fc
dest
.public Vector4f fma(Vector4fc a, Vector4fc b)
a * b
to this vector.a
- the first multiplicandb
- the second multiplicandpublic Vector4f fma(float a, Vector4fc b)
a * b
to this vector.a
- the first multiplicandb
- the second multiplicandpublic Vector4f fma(Vector4fc a, Vector4fc b, Vector4f dest)
Vector4fc
a * b
to this vector
and store the result in dest
.public Vector4f fma(float a, Vector4fc b, Vector4f dest)
Vector4fc
a * b
to this vector
and store the result in dest
.public Vector4f mul(Vector4fc v)
v
- the other vectorpublic Vector4f mul(Vector4fc v, Vector4f dest)
Vector4fc
dest
.public Vector4f div(Vector4fc v)
v
- the vector to divide bypublic Vector4f div(Vector4fc v, Vector4f dest)
Vector4fc
dest
.public Vector4f mul(Matrix4fc mat)
this
.mat
- the matrix to multiply the vector withpublic Vector4f mul(Matrix4fc mat, Vector4f dest)
Vector4fc
dest
.public Vector4f mul(Matrix4x3fc mat)
this
.mat
- the matrix to multiply the vector withpublic Vector4f mul(Matrix4x3fc mat, Vector4f dest)
Vector4fc
dest
.public Vector4f mulProject(Matrix4fc mat, Vector4f dest)
Vector4fc
mat
with this Vector4f, perform perspective division
and store the result in dest
.mulProject
in interface Vector4fc
mat
- the matrix to multiply this vector bydest
- will hold the resultpublic Vector4f mulProject(Matrix4fc mat)
mat
with this Vector4f, 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)
Vector4fc
Vector4f
by the given scalar
value and store the result in dest
.public 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)
Vector4fc
dest
.public Vector4f div(float scalar)
Vector4f
by the given scalar
value.scalar
- the scalar to divide bypublic Vector4f div(float scalar, Vector4f dest)
Vector4fc
Vector4f
by the given scalar
value and store the result in dest
.public 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)
Vector4fc
dest
.public Vector4f rotate(Quaternionfc quat)
quat
and store the result in this
.quat
- the quaternion to rotate this vectorQuaternionf.transform(Vector4f)
public Vector4f rotate(Quaternionfc quat, Vector4f dest)
Vector4fc
quat
and store the result in dest
.rotate
in interface Vector4fc
quat
- the quaternion to rotate this vectordest
- will hold the resultQuaternionf.transform(Vector4f)
public Vector4f rotateAbout(float angle, float x, float y, float z)
Reference: http://paulbourke.net
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 Vector4f rotateAbout(float angle, float x, float y, float z, Vector4f dest)
Vector4fc
dest
.
Reference: http://paulbourke.net
rotateAbout
in interface Vector4fc
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 axisdest
- will hold the resultpublic float lengthSquared()
Vector4fc
lengthSquared
in interface Vector4fc
public float length()
Vector4fc
public Vector4f normalize()
public Vector4f normalize(Vector4f dest)
Vector4fc
dest
.public Vector4f normalize3()
public float distance(Vector4fc v)
Vector4fc
this
vector and v
.public float distance(float x, float y, float z, float w)
Vector4fc
this
vector and (x, y, z, w).public float dot(Vector4fc v)
Vector4fc
v
.public float dot(float x, float y, float z, float w)
Vector4fc
public float angleCos(Vector4fc v)
Vector4fc
Math.cos(angle(v))
.angleCos
in interface Vector4fc
v
- the other vectorVector4fc.angle(Vector4fc)
public float angle(Vector4fc v)
Vector4fc
angle
in interface Vector4fc
v
- the other vectorVector4fc.angleCos(Vector4fc)
public Vector4f zero()
public Vector4f negate()
public Vector4f negate(Vector4f dest)
Vector4fc
dest
.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 Externalizable
IOException
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
IOException
ClassNotFoundException
public Vector4f min(Vector4fc v)
v
- the other vectorpublic Vector4f max(Vector4fc v)
v
- the other vectorpublic Vector4f smoothStep(Vector4fc v, float t, Vector4f dest)
Vector4fc
this
vector and the given vector v
and
store the result in dest
.smoothStep
in interface Vector4fc
v
- the other vectort
- the interpolation factor, within [0..1]dest
- will hold the resultpublic Vector4f hermite(Vector4fc t0, Vector4fc v1, Vector4fc t1, float t, Vector4f dest)
Vector4fc
this
vector and its
associated tangent t0
and the given vector v
with its tangent t1
and store the result in
dest
.public Vector4f lerp(Vector4fc 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(Vector4fc other, float t, Vector4f dest)
Vector4fc
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
.
public float get(int component) throws IllegalArgumentException
Vector4fc
get
in interface Vector4fc
component
- the component, within [0..3]IllegalArgumentException
- if component
is not within [0..3]public Vector4fc toImmutable()
Vector4f
.
The observable state of the returned object is the same as that of this
, but casting
the returned object to Vector4f will not be possible.
This method allocates a new instance of a class implementing Vector4fc on every call.
Copyright © 2015–2017 JOML. All rights reserved.