public class Vector4d extends Object implements Externalizable
Modifier and Type | Field and Description |
---|---|
double |
w
The w component of the vector.
|
double |
x
The x component of the vector.
|
double |
y
The y component of the vector.
|
double |
z
The z component of the vector.
|
Constructor and Description |
---|
Vector4d()
Create a new
Vector4d of (0, 0, 0, 1) . |
Vector4d(ByteBuffer buffer)
Create a new
Vector4f and read this vector from the supplied ByteBuffer
at the current buffer position . |
Vector4d(double d)
Create a new
Vector4d and initialize all four components with the given value. |
Vector4d(DoubleBuffer buffer)
Create a new
Vector4f and read this vector from the supplied DoubleBuffer
at the current buffer position . |
Vector4d(double x,
double y,
double z,
double w)
Create a new
Vector4f with the given component values. |
Vector4d(int index,
ByteBuffer buffer)
Create a new
Vector4f and read this vector from the supplied ByteBuffer
starting at the specified absolute buffer position/index. |
Vector4d(int index,
DoubleBuffer buffer)
Create a new
Vector4f and read this vector from the supplied DoubleBuffer
starting at the specified absolute buffer position/index. |
Vector4d(Vector2d v,
double z,
double w)
|
Vector4d(Vector2f v,
double z,
double w)
Create a new
Vector4d with the x and y components from the
given v and the z and w components from the given z and w . |
Vector4d(Vector3d v,
double w)
|
Vector4d(Vector3f v,
double w)
Create a new
Vector4d with the x, y, and z components from the
given v and the w component from the given w . |
Vector4d(Vector4d v)
Create a new
Vector4d with the same values as v . |
Vector4d(Vector4f v)
Create a new
Vector4d with the same values as v . |
Modifier and Type | Method and Description |
---|---|
Vector4d |
add(double x,
double y,
double z,
double w)
Add (x, y, z, w) to this.
|
Vector4d |
add(double x,
double y,
double z,
double w,
Vector4d dest)
Add (x, y, z, w) to this and store the result in
dest . |
Vector4d |
add(Vector4d v)
Add the supplied vector to this one.
|
static void |
add(Vector4d v1,
Vector4d v2,
Vector4d dest)
Add
v2 to v1 and store the result in dest . |
static void |
add(Vector4d v1,
Vector4f v2,
Vector4d dest)
Add
v2 to v1 and store the result in dest . |
Vector4d |
add(Vector4f v)
Add the supplied vector to this one.
|
static void |
add(Vector4f v1,
Vector4d v2,
Vector4d dest)
Add
v2 to v1 and store the result in dest . |
double |
angle(Vector4d v)
Return the angle between this vector and the supplied vector.
|
double |
angleCos(Vector4d v)
Return the cosine of the angle between this vector and the supplied vector.
|
double |
distance(double x,
double y,
double z,
double w)
Return the distance between
this vector and (x, y, z, w). |
double |
distance(Vector4d v)
Return the distance between
this vector and v . |
Vector4d |
div(double scalar)
Divide this Vector4d by the given scalar value.
|
Vector4d |
div(double scalar,
Vector4d dest)
Divide this Vector4d by the given scalar value and store the result in
dest . |
Vector4d |
div(Vector4d v)
|
Vector4d |
div(Vector4d v,
Vector4d dest)
|
double |
dot(double x,
double y,
double z,
double w)
Compute the dot product (inner product) of this vector and (x, y, z, w).
|
double |
dot(Vector4d v)
Compute the dot product (inner product) of this vector and
v . |
boolean |
equals(Object obj) |
Vector4d |
fma(double a,
Vector4d b)
Add the component-wise multiplication of
a * b to this vector. |
Vector4d |
fma(double a,
Vector4d b,
Vector4d dest)
Add the component-wise multiplication of
a * b to this vector
and store the result in dest . |
Vector4d |
fma(Vector4d a,
Vector4d b)
Add the component-wise multiplication of
a * b to this vector. |
Vector4d |
fma(Vector4d a,
Vector4d b,
Vector4d 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 . |
DoubleBuffer |
get(DoubleBuffer buffer)
Store this vector into the supplied
DoubleBuffer 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. |
DoubleBuffer |
get(int index,
DoubleBuffer buffer)
Store this vector into the supplied
DoubleBuffer starting at the specified
absolute buffer position/index. |
int |
hashCode() |
Vector4d |
hermite(Vector4d t0,
Vector4d v1,
Vector4d t1,
double t,
Vector4d 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 . |
double |
length()
Return the length of this vector.
|
double |
lengthSquared()
Return the length squared of this vector.
|
Vector4d |
lerp(Vector4d other,
double t)
Linearly interpolate
this and other using the given interpolation factor t
and store the result in this . |
Vector4d |
lerp(Vector4d other,
double t,
Vector4d dest)
Linearly interpolate
this and other using the given interpolation factor t
and store the result in dest . |
Vector4d |
mul(double scalar)
Multiply this Vector4d by the given scalar value.
|
Vector4d |
mul(double scalar,
Vector4d dest)
Multiply this Vector4d by the given scalar value and store the result in
dest . |
Vector4d |
mul(Matrix4d mat)
Multiply this
Vector4d by the given matrix mat . |
Vector4d |
mul(Matrix4d mat,
Vector4d dest)
Multiply this
Vector4d by the given matrix mat and store the result in dest . |
Vector4d |
mul(Matrix4f mat)
Multiply this
Vector4d by the given matrix mat . |
Vector4d |
mul(Matrix4f mat,
Vector4d dest)
Multiply this Vector4d by the given matrix mat and store the result in
dest . |
Vector4d |
mul(Vector4d v)
|
Vector4d |
mul(Vector4d v,
Vector4d dest)
|
Vector4d |
mul(Vector4f v)
|
Vector4d |
mulProject(Matrix4d mat)
Multiply this Vector4d by the given matrix
mat , perform perspective division. |
Vector4d |
mulProject(Matrix4d mat,
Vector4d dest)
Multiply this Vector4d by the given matrix
mat , perform perspective division
and store the result in dest . |
Vector4d |
negate()
Negate this vector.
|
Vector4d |
negate(Vector4d dest)
Negate this vector and store the result in
dest . |
Vector4d |
normalize()
Normalizes this vector.
|
Vector4d |
normalize(Vector4d dest)
Normalizes this vector and store the result in
dest . |
Vector4d |
normalize3()
Normalize this vector by computing only the norm of (x, y, z).
|
Vector4d |
normalize3(Vector4d dest)
Normalize this vector by computing only the norm of (x, y, z) and store the result in
dest . |
void |
readExternal(ObjectInput in) |
Vector4d |
rotate(Quaterniond quat)
Transform this vector by the given quaternion
quat and store the result in this . |
Vector4d |
rotate(Quaterniond quat,
Vector4d dest)
Transform this vector by the given quaternion
quat and store the result in dest . |
Vector4d |
set(ByteBuffer buffer)
Read this vector from the supplied
ByteBuffer at the current
buffer position . |
Vector4d |
set(double d)
Set the x, y, z, and w components to the supplied value.
|
Vector4d |
set(DoubleBuffer buffer)
Read this vector from the supplied
DoubleBuffer at the current
buffer position . |
Vector4d |
set(double x,
double y,
double z,
double w)
Set the x, y, z, and w components to the supplied values.
|
Vector4d |
set(int index,
ByteBuffer buffer)
Read this vector from the supplied
ByteBuffer starting at the specified
absolute buffer position/index. |
Vector4d |
set(int index,
DoubleBuffer buffer)
Read this vector from the supplied
DoubleBuffer starting at the specified
absolute buffer position/index. |
Vector4d |
set(Vector2d v,
double z,
double w)
Set the x and y components from the given
v
and the z and w components to the given z and w . |
Vector4d |
set(Vector2f v,
double z,
double w)
Set the x and y components from the given
v
and the z and w components to the given z and w . |
Vector4d |
set(Vector3d v,
double w)
Set the x, y, and z components of this to the components of
v and the w component to w . |
Vector4d |
set(Vector3f v,
double w)
Set the x, y, and z components of this to the components of
v and the w component to w . |
Vector4d |
set(Vector4d v)
Set this
Vector4d to the values of the given v . |
Vector4d |
set(Vector4f v)
Set this
Vector4d to the values of the given v . |
Vector4d |
smoothStep(Vector4d v,
double t,
Vector4d 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 . |
Vector4d |
sub(double x,
double y,
double z,
double w)
Subtract (x, y, z, w) from this.
|
Vector4d |
sub(double x,
double y,
double z,
double w,
Vector4d dest)
Subtract (x, y, z, w) from this and store the result in
dest . |
Vector4d |
sub(Vector4d v)
Subtract the supplied vector from this one.
|
static void |
sub(Vector4d v1,
Vector4d v2,
Vector4d dest)
Subtract
v2 from v1 and store the result in dest . |
static void |
sub(Vector4d v1,
Vector4f v2,
Vector4d dest)
Subtract
v2 from v1 and store the result in dest . |
Vector4d |
sub(Vector4f v)
Subtract the supplied vector from this one.
|
static void |
sub(Vector4f v1,
Vector4d v2,
Vector4d dest)
Subtract
v2 from v1 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) |
Vector4d |
zero()
Set all components to zero.
|
public double x
public double y
public double z
public double w
public Vector4d()
Vector4d
of (0, 0, 0, 1)
.public Vector4d(Vector4d v)
Vector4d
with the same values as v
.v
- the Vector4d
to copy the values frompublic Vector4d(Vector2d v, double z, double w)
v
- the Vector2d
z
- the z componentw
- the w componentpublic Vector4d(Vector4f v)
Vector4d
with the same values as v
.v
- the Vector4f
to copy the values frompublic Vector4d(Vector3f v, double w)
Vector4d
with the x, y, and z components from the
given v
and the w component from the given w
.v
- the Vector3f
w
- the w componentpublic Vector4d(Vector2f v, double z, double w)
Vector4d
with the x and y components from the
given v
and the z and w components from the given z
and w
.v
- the Vector2f
z
- the z componentw
- the w componentpublic Vector4d(double d)
Vector4d
and initialize all four components with the given value.d
- the value of all four componentspublic Vector4d(double x, double y, double z, double w)
Vector4f
with the given component values.x
- the x componenty
- the y componentz
- the z componentw
- the w componentpublic Vector4d(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 Vector4d(int, ByteBuffer)
, taking
the absolute position as parameter.
buffer
- values will be read in x, y, z, w orderVector4d(int, ByteBuffer)
public Vector4d(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 Vector4d(DoubleBuffer buffer)
Vector4f
and read this vector from the supplied DoubleBuffer
at the current buffer position
.
This method will not increment the position of the given DoubleBuffer.
In order to specify the offset into the DoubleBuffer at which
the vector is read, use Vector4d(int, DoubleBuffer)
, taking
the absolute position as parameter.
buffer
- values will be read in x, y, z, w orderVector4d(int, DoubleBuffer)
public Vector4d(int index, DoubleBuffer buffer)
Vector4f
and read this vector from the supplied DoubleBuffer
starting at the specified absolute buffer position/index.
This method will not increment the position of the given DoubleBuffer.
index
- the absolute position into the DoubleBufferbuffer
- values will be read in x, y, z, w orderpublic Vector4d set(Vector4d v)
Vector4d
to the values of the given v
.v
- the vector whose values will be copied into thispublic Vector4d set(Vector4f v)
Vector4d
to the values of the given v
.v
- the vector whose values will be copied into thispublic Vector4d set(Vector3d v, double w)
v
and the w component to w
.v
- the Vector3d
to copyw
- the w componentpublic Vector4d set(Vector3f v, double w)
v
and the w component to w
.v
- the Vector3f
to copyw
- the w componentpublic Vector4d set(Vector2d v, double z, double w)
v
and the z and w components to the given z
and w
.v
- the Vector2d
z
- the z componentw
- the w componentpublic Vector4d set(Vector2f v, double z, double w)
v
and the z and w components to the given z
and w
.v
- the Vector2f
z
- the z componentsw
- the w componentspublic Vector4d set(double d)
d
- the value of all four componentspublic Vector4d set(double x, double y, double z, double w)
x
- the x componenty
- the y componentz
- the z componentw
- the w componentpublic Vector4d 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 Vector4d 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 Vector4d set(DoubleBuffer buffer)
DoubleBuffer
at the current
buffer position
.
This method will not increment the position of the given DoubleBuffer.
In order to specify the offset into the DoubleBuffer at which
the vector is read, use set(int, DoubleBuffer)
, taking
the absolute position as parameter.
buffer
- values will be read in x, y, z, w orderset(int, DoubleBuffer)
public Vector4d set(int index, DoubleBuffer buffer)
DoubleBuffer
starting at the specified
absolute buffer position/index.
This method will not increment the position of the given DoubleBuffer.
index
- the absolute position into the DoubleBufferbuffer
- values will be read 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 DoubleBuffer get(DoubleBuffer buffer)
DoubleBuffer
at the current
buffer position
.
This method will not increment the position of the given DoubleBuffer.
In order to specify the offset into the DoubleBuffer at which
the vector is stored, use get(int, DoubleBuffer)
, taking
the absolute position as parameter.
buffer
- will receive the values of this vector in x, y, z, w orderget(int, DoubleBuffer)
public DoubleBuffer get(int index, DoubleBuffer buffer)
DoubleBuffer
starting at the specified
absolute buffer position/index.
This method will not increment the position of the given DoubleBuffer.
index
- the absolute position into the DoubleBufferbuffer
- will receive the values of this vector in x, y, z, w orderpublic Vector4d sub(Vector4d v)
v
- the vector to subtractpublic Vector4d sub(Vector4f v)
v
- the vector to subtractpublic Vector4d sub(double x, double y, double z, double w)
x
- the x component to subtracty
- the y component to subtractz
- the z component to subtractw
- the w component to subtractpublic Vector4d sub(double x, double y, double z, double w, Vector4d 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 static void sub(Vector4d v1, Vector4d v2, Vector4d dest)
v2
from v1
and store the result in dest
.v1
- the left operandv2
- the right operanddest
- will hold the resultpublic static void sub(Vector4d v1, Vector4f v2, Vector4d dest)
v2
from v1
and store the result in dest
.v1
- the left operandv2
- the right operanddest
- will hold the resultpublic static void sub(Vector4f v1, Vector4d v2, Vector4d dest)
v2
from v1
and store the result in dest
.v1
- the left operandv2
- the right operanddest
- will hold the resultpublic Vector4d add(Vector4d v)
v
- the vector to addpublic Vector4d add(double x, double y, double z, double w)
x
- the x component to subtracty
- the y component to subtractz
- the z component to subtractw
- the w component to subtractpublic Vector4d add(double x, double y, double z, double w, Vector4d 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 Vector4d add(Vector4f v)
v
- the vector to addpublic static void add(Vector4d v1, Vector4d v2, Vector4d dest)
v2
to v1
and store the result in dest
.v1
- the first addendv2
- the second addenddest
- will hold the resultpublic static void add(Vector4d v1, Vector4f v2, Vector4d dest)
v2
to v1
and store the result in dest
.v1
- the first addendv2
- the second addenddest
- will hold the resultpublic static void add(Vector4f v1, Vector4d v2, Vector4d dest)
v2
to v1
and store the result in dest
.v1
- the first addendv2
- the second addenddest
- will hold the resultpublic Vector4d fma(Vector4d a, Vector4d b)
a * b
to this vector.a
- the first multiplicandb
- the second multiplicandpublic Vector4d fma(double a, Vector4d b)
a * b
to this vector.a
- the first multiplicandb
- the second multiplicandpublic Vector4d fma(Vector4d a, Vector4d b, Vector4d dest)
a * b
to this vector
and store the result in dest
.a
- the first multiplicandb
- the second multiplicanddest
- will hold the resultpublic Vector4d fma(double a, Vector4d b, Vector4d dest)
a * b
to this vector
and store the result in dest
.a
- the first multiplicandb
- the second multiplicanddest
- will hold the resultpublic Vector4d mul(Vector4d v, Vector4d dest)
v
- the vector to multiply this bydest
- will hold the resultpublic Vector4d div(Vector4d v, Vector4d dest)
v
- the vector to divide this bydest
- will hold the resultpublic Vector4d mul(Matrix4d mat)
Vector4d
by the given matrix mat
.mat
- the matrix to multiply bypublic Vector4d mul(Matrix4d mat, Vector4d dest)
Vector4d
by the given matrix mat and store the result in dest
.mat
- the matrix to multiply this
bydest
- will hold the resultpublic Vector4d mul(Matrix4f mat)
Vector4d
by the given matrix mat
.mat
- the matrix to multiply bypublic Vector4d mul(Matrix4f mat, Vector4d dest)
dest
.mat
- the matrix to multiply this
bydest
- will hold the resultpublic Vector4d mulProject(Matrix4d mat, Vector4d dest)
mat
, perform perspective division
and store the result in dest
.mat
- the matrix to multiply this vector bydest
- will hold the resultpublic Vector4d mulProject(Matrix4d mat)
mat
, perform perspective division.mat
- the matrix to multiply this vector bypublic Vector4d mul(double scalar)
scalar
- the scalar to multiply bypublic Vector4d mul(double scalar, Vector4d dest)
dest
.scalar
- the factor to multiply bydest
- will hold the resultpublic Vector4d div(double scalar)
scalar
- the scalar to divide bypublic Vector4d div(double scalar, Vector4d dest)
dest
.scalar
- the factor to divide bydest
- will hold the resultpublic Vector4d rotate(Quaterniond quat)
quat
and store the result in this
.quat
- the quaternion to transform this vectorQuaterniond.transform(Vector4d)
public Vector4d rotate(Quaterniond quat, Vector4d dest)
quat
and store the result in dest
.quat
- the quaternion to transform this vectordest
- will hold the resultQuaterniond.transform(Vector4d)
public double lengthSquared()
public double length()
public Vector4d normalize()
public Vector4d normalize(Vector4d dest)
dest
.dest
- will hold the resultpublic Vector4d normalize3()
public Vector4d normalize3(Vector4d dest)
dest
.dest
- will hold the resultpublic double distance(Vector4d v)
this
vector and v
.v
- the other vectorpublic double distance(double x, double y, double z, double 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 double dot(Vector4d v)
v
.v
- the other vectorpublic double dot(double x, double y, double z, double 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 double angleCos(Vector4d v)
Use this instead of Math.cos(angle(v))
.
v
- the other vectorangle(Vector4d)
public double angle(Vector4d v)
v
- the other vectorangleCos(Vector4d)
public Vector4d zero()
public Vector4d negate()
public Vector4d negate(Vector4d 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 Externalizable
IOException
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
IOException
ClassNotFoundException
public Vector4d smoothStep(Vector4d v, double t, Vector4d 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 Vector4d hermite(Vector4d t0, Vector4d v1, Vector4d t1, double t, Vector4d 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 Vector4d lerp(Vector4d other, double 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 Vector4d lerp(Vector4d other, double t, Vector4d 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.