public class Vector2d extends Object implements Externalizable
Modifier and Type | Field and Description |
---|---|
double |
x
The x component of the vector.
|
double |
y
The y component of the vector.
|
Constructor and Description |
---|
Vector2d()
Create a new
Vector2d and initialize its components to zero. |
Vector2d(ByteBuffer buffer)
Create a new
Vector2d and read this vector from the supplied ByteBuffer
at the current buffer position . |
Vector2d(double d)
Create a new
Vector2d and initialize both of its components with the given value. |
Vector2d(DoubleBuffer buffer)
Create a new
Vector2d and read this vector from the supplied DoubleBuffer
at the current buffer position . |
Vector2d(double x,
double y)
Create a new
Vector2d and initialize its components to the given values. |
Vector2d(int index,
ByteBuffer buffer)
Create a new
Vector2d and read this vector from the supplied ByteBuffer
starting at the specified absolute buffer position/index. |
Vector2d(int index,
DoubleBuffer buffer)
Create a new
Vector2d and read this vector from the supplied DoubleBuffer
starting at the specified absolute buffer position/index. |
Vector2d(Vector2d v)
Create a new
Vector2d and initialize its components to the one of the given vector. |
Vector2d(Vector2f v)
Create a new
Vector2d and initialize its components to the one of the given vector. |
Modifier and Type | Method and Description |
---|---|
Vector2d |
add(double x,
double y)
Add
(x, y) to this vector. |
Vector2d |
add(double x,
double y,
Vector2d dest)
Add
(x, y) to this vector and store the result in dest . |
Vector2d |
add(Vector2d v)
Add
v to this vector. |
Vector2d |
add(Vector2d v,
Vector2d dest)
Add
v to this vector and store the result in dest . |
Vector2d |
add(Vector2f v)
Add
v to this vector. |
Vector2d |
add(Vector2f v,
Vector2d dest)
Add
v to this vector and store the result in dest . |
static void |
add(Vector2f a,
Vector2d b,
Vector2d dest)
Add
a to b and store the result in dest . |
double |
angle(Vector2d v)
Return the angle between this vector and the supplied vector.
|
double |
distance(Vector2d v)
Return the distance between
this and v . |
double |
distance(Vector2f v)
Return the distance between
this and v . |
double |
dot(Vector2d v)
Return the dot product of this vector and
v . |
boolean |
equals(Object obj) |
Vector2d |
fma(double a,
Vector2d b)
Add the component-wise multiplication of
a * b to this vector. |
Vector2d |
fma(double a,
Vector2d b,
Vector2d dest)
Add the component-wise multiplication of
a * b to this vector
and store the result in dest . |
Vector2d |
fma(Vector2d a,
Vector2d b)
Add the component-wise multiplication of
a * b to this vector. |
Vector2d |
fma(Vector2d a,
Vector2d b,
Vector2d 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() |
double |
length()
Return the length of this vector.
|
Vector2d |
lerp(Vector2d other,
double t)
Linearly interpolate
this and other using the given interpolation factor t
and store the result in this . |
Vector2d |
lerp(Vector2d other,
double t,
Vector2d dest)
Linearly interpolate
this and other using the given interpolation factor t
and store the result in dest . |
Vector2d |
negate()
Negate this vector.
|
Vector2d |
negate(Vector2d dest)
Negate this vector and store the result in
dest . |
Vector2d |
normalize()
Normalize this vector.
|
Vector2d |
normalize(Vector2d dest)
Normalize this vector and store the result in
dest . |
Vector2d |
perpendicular()
Set this vector to be one of its perpendicular vectors.
|
static void |
perpendicular(Vector2d v,
Vector2d dest)
Store one perpendicular vector of
v in dest . |
void |
readExternal(ObjectInput in) |
Vector2d |
set(ByteBuffer buffer)
Read this vector from the supplied
ByteBuffer at the current
buffer position . |
Vector2d |
set(double d)
Set the x and y components to the supplied value.
|
Vector2d |
set(DoubleBuffer buffer)
Read this vector from the supplied
DoubleBuffer at the current
buffer position . |
Vector2d |
set(double x,
double y)
Set the x and y components to the supplied values.
|
Vector2d |
set(int index,
ByteBuffer buffer)
Read this vector from the supplied
ByteBuffer starting at the specified
absolute buffer position/index. |
Vector2d |
set(int index,
DoubleBuffer buffer)
Read this vector from the supplied
DoubleBuffer starting at the specified
absolute buffer position/index. |
Vector2d |
set(Vector2d v)
Set this
Vector2d to the values of v. |
Vector2d |
set(Vector2f v)
Set this
Vector2d to be a clone of v . |
Vector2d |
sub(double x,
double y)
Subtract (x, y) from this vector.
|
Vector2d |
sub(double x,
double y,
Vector2d dest)
Subtract (x, y) from this vector and store the result in
dest . |
Vector2d |
sub(Vector2d v)
Subtract
v from this vector. |
Vector2d |
sub(Vector2d v,
Vector2d dest)
Subtract
v from this vector and store the result in dest . |
Vector2d |
sub(Vector2f v)
Subtract
v from this vector. |
Vector2d |
sub(Vector2f v,
Vector2d dest)
Subtract
v from this vector and store the result in dest . |
static void |
sub(Vector2f a,
Vector2d b,
Vector2d dest)
Subtract
b from a 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) |
Vector2d |
zero()
Set all components to zero.
|
public double x
public double y
public Vector2d()
Vector2d
and initialize its components to zero.public Vector2d(double d)
Vector2d
and initialize both of its components with the given value.d
- the value of both componentspublic Vector2d(double x, double y)
Vector2d
and initialize its components to the given values.x
- the x valuey
- the y valuepublic Vector2d(Vector2d v)
Vector2d
and initialize its components to the one of the given vector.v
- the Vector2d
to copy the values frompublic Vector2d(Vector2f v)
Vector2d
and initialize its components to the one of the given vector.v
- the Vector2f
to copy the values frompublic Vector2d(ByteBuffer buffer)
Vector2d
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 Vector2d(int, ByteBuffer)
, taking
the absolute position as parameter.
buffer
- values will be read in x, y orderVector2d(int, ByteBuffer)
public Vector2d(int index, ByteBuffer buffer)
Vector2d
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 orderpublic Vector2d(DoubleBuffer buffer)
Vector2d
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 Vector2d(int, DoubleBuffer)
, taking
the absolute position as parameter.
buffer
- values will be read in x, y orderVector2d(int, DoubleBuffer)
public Vector2d(int index, DoubleBuffer buffer)
Vector2d
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 orderpublic Vector2d set(double d)
d
- the value of both componentspublic Vector2d set(double x, double y)
x
- the x valuey
- the y valuepublic Vector2d set(Vector2d v)
Vector2d
to the values of v.v
- the vector to copy frompublic Vector2d set(Vector2f v)
Vector2d
to be a clone of v
.v
- the vector to copy frompublic Vector2d 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 orderset(int, ByteBuffer)
public Vector2d 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 orderpublic Vector2d 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 orderset(int, DoubleBuffer)
public Vector2d 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 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 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 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 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 orderpublic static void perpendicular(Vector2d v, Vector2d dest)
v
in dest
.v
- the vector to build one perpendicular vector ofdest
- will hold the resultpublic Vector2d perpendicular()
public Vector2d sub(Vector2d v)
v
from this vector.v
- the vector to subtractpublic Vector2d sub(double x, double y)
x
- the x component to subtracty
- the y component to subtractpublic Vector2d sub(double x, double y, Vector2d dest)
dest
.x
- the x component to subtracty
- the y component to subtractdest
- will hold the resultpublic Vector2d sub(Vector2f v)
v
from this vector.v
- the vector to subtractpublic Vector2d sub(Vector2d v, Vector2d dest)
v
from this
vector and store the result in dest
.v
- the vector to subtractdest
- will hold the resultpublic Vector2d sub(Vector2f v, Vector2d dest)
v
from this
vector and store the result in dest
.v
- the vector to subtractdest
- will hold the resultpublic static void sub(Vector2f a, Vector2d b, Vector2d dest)
b
from a
and store the result in dest
.a
- the vector to subtract fromb
- the vector to subtractdest
- will hold the resultpublic double dot(Vector2d v)
v
.v
- the other vectorpublic double angle(Vector2d v)
v
- the other vectorpublic double length()
public double distance(Vector2d v)
this
and v
.v
- the other vectorpublic double distance(Vector2f v)
this
and v
.v
- the other vectorpublic Vector2d normalize()
public Vector2d normalize(Vector2d dest)
dest
.dest
- will hold the resultpublic Vector2d add(Vector2d v)
v
to this vector.v
- the vector to addpublic Vector2d add(double x, double y)
(x, y)
to this vector.x
- the x component to addy
- the y component to addpublic Vector2d add(double x, double y, Vector2d dest)
(x, y)
to this vector and store the result in dest
.x
- the x component to addy
- the y component to adddest
- will hold the resultpublic Vector2d add(Vector2f v)
v
to this vector.v
- the vector to addpublic Vector2d add(Vector2d v, Vector2d dest)
v
to this vector and store the result in dest
.v
- the vector to adddest
- will hold the resultpublic Vector2d add(Vector2f v, Vector2d dest)
v
to this vector and store the result in dest
.v
- the vector to adddest
- will hold the resultpublic static void add(Vector2f a, Vector2d b, Vector2d dest)
a
to b
and store the result in dest
.a
- the first addendb
- the second addenddest
- will hold the resultpublic Vector2d zero()
public 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 Vector2d negate()
public Vector2d negate(Vector2d dest)
dest
.dest
- will hold the resultpublic Vector2d lerp(Vector2d 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 Vector2d lerp(Vector2d other, double t, Vector2d 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 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 Vector2d fma(Vector2d a, Vector2d b)
a * b
to this vector.a
- the first multiplicandb
- the second multiplicandpublic Vector2d fma(double a, Vector2d b)
a * b
to this vector.a
- the first multiplicandb
- the second multiplicandpublic Vector2d fma(Vector2d a, Vector2d b, Vector2d dest)
a * b
to this vector
and store the result in dest
.a
- the first multiplicandb
- the second multiplicanddest
- will hold the resultCopyright © 2015–2016 JOML. All rights reserved.