Class Vector2d
- All Implemented Interfaces:
Externalizable
,Serializable
,Cloneable
,Vector2dc
- Author:
- RGreenlees, Kai Burjack, F. Neurath
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorDescriptionVector2d()
Create a newVector2d
and initialize its components to zero.Vector2d
(double d) Create a newVector2d
and initialize both of its components with the given value.Vector2d
(double[] xy) Create a newVector2d
and initialize its two components from the first two elements of the given array.Vector2d
(double x, double y) Create a newVector2d
and initialize its components to the given values.Vector2d
(float[] xy) Create a newVector2d
and initialize its two components from the first two elements of the given array.Vector2d
(int index, ByteBuffer buffer) Create a newVector2d
and read this vector from the suppliedByteBuffer
starting at the specified absolute buffer position/index.Vector2d
(int index, DoubleBuffer buffer) Create a newVector2d
and read this vector from the suppliedDoubleBuffer
starting at the specified absolute buffer position/index.Vector2d
(ByteBuffer buffer) Create a newVector2d
and read this vector from the suppliedByteBuffer
at the current bufferposition
.Vector2d
(DoubleBuffer buffer) Create a newVector2d
and read this vector from the suppliedDoubleBuffer
at the current bufferposition
.Create a newVector2d
and initialize its components to the one of the given vector.Create a newVector2d
and initialize its components to the one of the given vector.Create a newVector2d
and initialize its components to the one of the given vector. -
Method Summary
Modifier and TypeMethodDescriptionabsolute()
Setthis
vector's components to their respective absolute values.Compute the absolute of each of this vector's components and store the result intodest
.add
(double x, double y) Add(x, y)
to this vector.Add(x, y)
to this vector and store the result indest
.Addv
to this vector.Addv
to this vector and store the result indest
.Addv
to this vector.Addv
to this vector and store the result indest
.double
Return the angle between this vector and the supplied vector.ceil()
Set each component of this vector to the smallest (closest to negative infinity)double
value that is greater than or equal to that component and is equal to a mathematical integer.Compute for each component of this vector the smallest (closest to negative infinity)double
value that is greater than or equal to that component and is equal to a mathematical integer and store the result indest
.clone()
double
distance
(double x, double y) Return the distance betweenthis
vector and(x, y)
.static double
distance
(double x1, double y1, double x2, double y2) Return the distance between(x1, y1)
and(x2, y2)
.double
Return the distance between this andv
.double
Return the distance between this andv
.double
distanceSquared
(double x, double y) Return the distance squared betweenthis
vector and(x, y)
.static double
distanceSquared
(double x1, double y1, double x2, double y2) Return the squared distance between(x1, y1)
and(x2, y2)
.double
Return the distance squared between this andv
.double
Return the distance squared between this andv
.div
(double scalar) Divide this Vector2d by the given scalar value.div
(double x, double y) Divide the components of this Vector2d by the given scalar values and store the result inthis
.Divide the components of this Vector3f by the given scalar values and store the result indest
.Divide this Vector2d by the given scalar value and store the result indest
.Divide this Vector2d component-wise by another Vector2dc.Divide this byv
component-wise and store the result intodest
.Divide this Vector3d component-wise by another Vector2fc.Divide this Vector2d component-wise by another Vector2f and store the result indest
.double
Return the dot product of this vector andv
.boolean
equals
(double x, double y) Compare the vector components ofthis
vector with the given(x, y)
and return whether all of them are equal.boolean
boolean
Compare the vector components ofthis
vector with the given vector using the givendelta
and return whether all of them are equal within a maximum difference ofdelta
.floor()
Set each component of this vector to the largest (closest to positive infinity)double
value that is less than or equal to that component and is equal to a mathematical integer.Compute for each component of this vector the largest (closest to positive infinity)double
value that is less than or equal to that component and is equal to a mathematical integer and store the result indest
.Add the component-wise multiplication ofa * b
to this vector.Add the component-wise multiplication ofa * b
to this vector and store the result indest
.Add the component-wise multiplication ofa * b
to this vector.Add the component-wise multiplication ofa * b
to this vector and store the result indest
.double
get
(int component) Get the value of the specified component of this vector.get
(int index, ByteBuffer buffer) Store this vector into the suppliedByteBuffer
starting at the specified absolute buffer position/index.get
(int index, DoubleBuffer buffer) Store this vector into the suppliedDoubleBuffer
starting at the specified absolute buffer position/index.get
(ByteBuffer buffer) Store this vector into the suppliedByteBuffer
at the current bufferposition
.get
(DoubleBuffer buffer) Store this vector into the suppliedDoubleBuffer
at the current bufferposition
.Set the components of the given vectordest
to those ofthis
vector.Set the components of the given vectordest
to those ofthis
vector.getToAddress
(long address) Store this vector at the given off-heap memory address.int
hashCode()
boolean
isFinite()
double
length()
Return the length of this vector.static double
length
(double x, double y) Get the length of a 2-dimensional double-precision vector.double
Return the length squared of this vector.static double
lengthSquared
(double x, double y) Get the length squared of a 2-dimensional double-precision vector.Linearly interpolatethis
andother
using the given interpolation factort
and store the result inthis
.Linearly interpolatethis
andother
using the given interpolation factort
and store the result indest
.Set the components of this vector to be the component-wise maximum of this and the other vector.Set the components ofdest
to be the component-wise maximum of this and the other vector.int
Determine the component with the biggest absolute value.Set the components of this vector to be the component-wise minimum of this and the other vector.Set the components ofdest
to be the component-wise minimum of this and the other vector.int
Determine the component with the smallest (towards zero) absolute value.mul
(double scalar) Multiply the components of this vector by the given scalar.mul
(double x, double y) Multiply the components of this Vector2d by the given scalar values and store the result inthis
.Multiply the components of this Vector2d by the given scalar values and store the result indest
.Multiply the components of this vector by the given scalar and store the result indest
.Multiply the given matrixmat
with this Vector2d.Multiply the given matrixmat
withthis
and store the result indest
.Multiply the given matrixmat
with this Vector2d.Multiply the given matrixmat
withthis
and store the result indest
.Multiply this Vector2d component-wise by another Vector2d.Multiply this Vector2d component-wise by another Vector2d and store the result indest
.mulDirection
(Matrix3x2dc mat) Multiply the given 3x2 matrixmat
withthis
.mulDirection
(Matrix3x2dc mat, Vector2d dest) Multiply the given 3x2 matrixmat
withthis
and store the result indest
.mulPosition
(Matrix3x2dc mat) Multiply the given 3x2 matrixmat
withthis
.mulPosition
(Matrix3x2dc mat, Vector2d dest) Multiply the given 3x2 matrixmat
withthis
and store the result indest
.mulTranspose
(Matrix2dc mat) Multiply the transpose of the given matrix with this Vector2d and store the result inthis
.mulTranspose
(Matrix2dc mat, Vector2d dest) Multiply the transpose of the given matrix with this Vector2f and store the result indest
.mulTranspose
(Matrix2fc mat) Multiply the transpose of the given matrix with this Vector2d and store the result inthis
.mulTranspose
(Matrix2fc mat, Vector2d dest) Multiply the transpose of the given matrix with this Vector2f and store the result indest
.negate()
Negate this vector.Negate this vector and store the result indest
.Normalize this vector.normalize
(double length) Scale this vector to have the given length.Scale this vector to have the given length and store the result indest
.Normalize this vector and store the result indest
.Set this vector to be one of its perpendicular vectors.void
round()
Set each component of this vector to the closest double that is equal to a mathematical integer, with ties rounding to positive infinity.Compute for each component of this vector the closest double that is equal to a mathematical integer, with ties rounding to positive infinity and store the result indest
.set
(double d) Set the x and y components to the supplied value.set
(double[] xy) Set the two components of this vector to the first two elements of the given array.set
(double x, double y) Set the x and y components to the supplied values.set
(float[] xy) Set the two components of this vector to the first two elements of the given array.set
(int index, ByteBuffer buffer) Read this vector from the suppliedByteBuffer
starting at the specified absolute buffer position/index.set
(int index, DoubleBuffer buffer) Read this vector from the suppliedDoubleBuffer
starting at the specified absolute buffer position/index.set
(ByteBuffer buffer) Read this vector from the suppliedByteBuffer
at the current bufferposition
.set
(DoubleBuffer buffer) Read this vector from the suppliedDoubleBuffer
at the current bufferposition
.Set thisVector2d
to the values of v.Set thisVector2d
to be a clone ofv
.Set thisVector2d
to be a clone ofv
.setComponent
(int component, double value) Set the value of the specified component of this vector.setFromAddress
(long address) Set the values of this vector by reading 2 double values from off-heap memory, starting at the given address.sub
(double x, double y) Subtract(x, y)
from this vector.Subtract(x, y)
from this vector and store the result indest
.Subtractv
from this vector.Subtractv
fromthis
vector and store the result indest
.Subtractv
from this vector.Subtractv
fromthis
vector and store the result indest
.toString()
Return a string representation of this vector.toString
(NumberFormat formatter) Return a string representation of this vector by formatting the vector components with the givenNumberFormat
.void
double
x()
double
y()
zero()
Set all components to zero.
-
Field Details
-
x
public double xThe x component of the vector. -
y
public double yThe y component of the vector.
-
-
Constructor Details
-
Vector2d
public Vector2d()Create a newVector2d
and initialize its components to zero. -
Vector2d
public Vector2d(double d) Create a newVector2d
and initialize both of its components with the given value.- Parameters:
d
- the value of both components
-
Vector2d
public Vector2d(double x, double y) Create a newVector2d
and initialize its components to the given values.- Parameters:
x
- the x valuey
- the y value
-
Vector2d
Create a newVector2d
and initialize its components to the one of the given vector.- Parameters:
v
- theVector2dc
to copy the values from
-
Vector2d
Create a newVector2d
and initialize its components to the one of the given vector.- Parameters:
v
- theVector2fc
to copy the values from
-
Vector2d
Create a newVector2d
and initialize its components to the one of the given vector.- Parameters:
v
- theVector2ic
to copy the values from
-
Vector2d
public Vector2d(double[] xy) Create a newVector2d
and initialize its two components from the first two elements of the given array.- Parameters:
xy
- the array containing at least three elements
-
Vector2d
public Vector2d(float[] xy) Create a newVector2d
and initialize its two components from the first two elements of the given array.- Parameters:
xy
- the array containing at least two elements
-
Vector2d
Create a newVector2d
and read this vector from the suppliedByteBuffer
at the current bufferposition
.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.- Parameters:
buffer
- values will be read inx, y
order- See Also:
-
Vector2d
Create a newVector2d
and read this vector from the suppliedByteBuffer
starting at the specified absolute buffer position/index.This method will not increment the position of the given ByteBuffer.
- Parameters:
index
- the absolute position into the ByteBufferbuffer
- values will be read inx, y
order
-
Vector2d
Create a newVector2d
and read this vector from the suppliedDoubleBuffer
at the current bufferposition
.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.- Parameters:
buffer
- values will be read inx, y
order- See Also:
-
Vector2d
Create a newVector2d
and read this vector from the suppliedDoubleBuffer
starting at the specified absolute buffer position/index.This method will not increment the position of the given DoubleBuffer.
- Parameters:
index
- the absolute position into the DoubleBufferbuffer
- values will be read inx, y
order
-
-
Method Details
-
x
public double x() -
y
public double y() -
set
Set the x and y components to the supplied value.- Parameters:
d
- the value of both components- Returns:
- this
-
set
Set the x and y components to the supplied values.- Parameters:
x
- the x valuey
- the y value- Returns:
- this
-
set
Set thisVector2d
to the values of v.- Parameters:
v
- the vector to copy from- Returns:
- this
-
set
Set thisVector2d
to be a clone ofv
.- Parameters:
v
- the vector to copy from- Returns:
- this
-
set
Set thisVector2d
to be a clone ofv
.- Parameters:
v
- the vector to copy from- Returns:
- this
-
set
Set the two components of this vector to the first two elements of the given array.- Parameters:
xy
- the array containing at least three elements- Returns:
- this
-
set
Set the two components of this vector to the first two elements of the given array.- Parameters:
xy
- the array containing at least two elements- Returns:
- this
-
set
Read this vector from the suppliedByteBuffer
at the current bufferposition
.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.- Parameters:
buffer
- values will be read inx, y
order- Returns:
- this
- See Also:
-
set
Read this vector from the suppliedByteBuffer
starting at the specified absolute buffer position/index.This method will not increment the position of the given ByteBuffer.
- Parameters:
index
- the absolute position into the ByteBufferbuffer
- values will be read inx, y
order- Returns:
- this
-
set
Read this vector from the suppliedDoubleBuffer
at the current bufferposition
.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.- Parameters:
buffer
- values will be read inx, y
order- Returns:
- this
- See Also:
-
set
Read this vector from the suppliedDoubleBuffer
starting at the specified absolute buffer position/index.This method will not increment the position of the given DoubleBuffer.
- Parameters:
index
- the absolute position into the DoubleBufferbuffer
- values will be read inx, y
order- Returns:
- this
-
setFromAddress
Set the values of this vector by reading 2 double values from off-heap memory, starting at the given address.This method will throw an
UnsupportedOperationException
when JOML is used with `-Djoml.nounsafe`.This method is unsafe as it can result in a crash of the JVM process when the specified address range does not belong to this process.
- Parameters:
address
- the off-heap memory address to read the vector values from- Returns:
- this
-
get
Description copied from interface:Vector2dc
Get the value of the specified component of this vector.- Specified by:
get
in interfaceVector2dc
- Parameters:
component
- the component, within[0..1]
- Returns:
- the value
- Throws:
IllegalArgumentException
- ifcomponent
is not within[0..1]
-
get
Description copied from interface:Vector2dc
- Specified by:
get
in interfaceVector2dc
- Parameters:
mode
- theRoundingMode
to usedest
- will hold the result- Returns:
- dest
-
get
Description copied from interface:Vector2dc
Set the components of the given vectordest
to those ofthis
vector. -
get
Description copied from interface:Vector2dc
Set the components of the given vectordest
to those ofthis
vector. -
setComponent
Set the value of the specified component of this vector.- Parameters:
component
- the component whose value to set, within[0..1]
value
- the value to set- Returns:
- this
- Throws:
IllegalArgumentException
- ifcomponent
is not within[0..1]
-
get
Description copied from interface:Vector2dc
Store this vector into the suppliedByteBuffer
at the current bufferposition
.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
Vector2dc.get(int, ByteBuffer)
, taking the absolute position as parameter. -
get
Description copied from interface:Vector2dc
Store this vector into the suppliedByteBuffer
starting at the specified absolute buffer position/index.This method will not increment the position of the given ByteBuffer.
-
get
Description copied from interface:Vector2dc
Store this vector into the suppliedDoubleBuffer
at the current bufferposition
.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
Vector2dc.get(int, DoubleBuffer)
, taking the absolute position as parameter. -
get
Description copied from interface:Vector2dc
Store this vector into the suppliedDoubleBuffer
starting at the specified absolute buffer position/index.This method will not increment the position of the given DoubleBuffer.
-
getToAddress
Description copied from interface:Vector2dc
Store this vector at the given off-heap memory address.This method will throw an
UnsupportedOperationException
when JOML is used with `-Djoml.nounsafe`.This method is unsafe as it can result in a crash of the JVM process when the specified address range does not belong to this process.
- Specified by:
getToAddress
in interfaceVector2dc
- Parameters:
address
- the off-heap address where to store this vector- Returns:
- this
-
perpendicular
Set this vector to be one of its perpendicular vectors.- Returns:
- this
-
sub
Subtractv
from this vector.- Parameters:
v
- the vector to subtract- Returns:
- this
-
sub
Subtract(x, y)
from this vector.- Parameters:
x
- the x component to subtracty
- the y component to subtract- Returns:
- this
-
sub
Description copied from interface:Vector2dc
Subtract(x, y)
from this vector and store the result indest
. -
sub
Subtractv
from this vector.- Parameters:
v
- the vector to subtract- Returns:
- this
-
sub
Description copied from interface:Vector2dc
Subtractv
fromthis
vector and store the result indest
. -
sub
Description copied from interface:Vector2dc
Subtractv
fromthis
vector and store the result indest
. -
mul
Multiply the components of this vector by the given scalar.- Parameters:
scalar
- the value to multiply this vector's components by- Returns:
- this
-
mul
Description copied from interface:Vector2dc
Multiply the components of this vector by the given scalar and store the result indest
. -
mul
Multiply the components of this Vector2d by the given scalar values and store the result inthis
.- Parameters:
x
- the x component to multiply this vector byy
- the y component to multiply this vector by- Returns:
- this
-
mul
Description copied from interface:Vector2dc
Multiply the components of this Vector2d by the given scalar values and store the result indest
. -
mul
Multiply this Vector2d component-wise by another Vector2d.- Parameters:
v
- the vector to multiply by- Returns:
- this
-
mul
Description copied from interface:Vector2dc
Multiply this Vector2d component-wise by another Vector2d and store the result indest
. -
div
Divide this Vector2d by the given scalar value.- Parameters:
scalar
- the scalar to divide this vector by- Returns:
- this
-
div
Description copied from interface:Vector2dc
Divide this Vector2d by the given scalar value and store the result indest
. -
div
Divide the components of this Vector2d by the given scalar values and store the result inthis
.- Parameters:
x
- the x component to divide this vector byy
- the y component to divide this vector by- Returns:
- this
-
div
Description copied from interface:Vector2dc
Divide the components of this Vector3f by the given scalar values and store the result indest
. -
div
Divide this Vector2d component-wise by another Vector2dc.- Parameters:
v
- the vector to divide by- Returns:
- this
-
div
Divide this Vector3d component-wise by another Vector2fc.- Parameters:
v
- the vector to divide by- Returns:
- this
-
div
Description copied from interface:Vector2dc
Divide this Vector2d component-wise by another Vector2f and store the result indest
. -
div
Description copied from interface:Vector2dc
Divide this byv
component-wise and store the result intodest
. -
mul
Multiply the given matrixmat
with this Vector2d.- Parameters:
mat
- the matrix to multiply this vector by- Returns:
- this
-
mul
Multiply the given matrixmat
with this Vector2d.- Parameters:
mat
- the matrix to multiply this vector by- Returns:
- this
-
mul
Description copied from interface:Vector2dc
Multiply the given matrixmat
withthis
and store the result indest
. -
mul
Description copied from interface:Vector2dc
Multiply the given matrixmat
withthis
and store the result indest
. -
mulTranspose
Multiply the transpose of the given matrix with this Vector2d and store the result inthis
.- Parameters:
mat
- the matrix- Returns:
- this
-
mulTranspose
Description copied from interface:Vector2dc
Multiply the transpose of the given matrix with this Vector2f and store the result indest
.- Specified by:
mulTranspose
in interfaceVector2dc
- Parameters:
mat
- the matrixdest
- will hold the result- Returns:
- dest
-
mulTranspose
Multiply the transpose of the given matrix with this Vector2d and store the result inthis
.- Parameters:
mat
- the matrix- Returns:
- this
-
mulTranspose
Description copied from interface:Vector2dc
Multiply the transpose of the given matrix with this Vector2f and store the result indest
.- Specified by:
mulTranspose
in interfaceVector2dc
- Parameters:
mat
- the matrixdest
- will hold the result- Returns:
- dest
-
mulPosition
Multiply the given 3x2 matrixmat
withthis
.This method assumes the
z
component ofthis
to be1.0
.- Parameters:
mat
- the matrix to multiply this vector by- Returns:
- this
-
mulPosition
Description copied from interface:Vector2dc
Multiply the given 3x2 matrixmat
withthis
and store the result indest
.This method assumes the
z
component ofthis
to be1.0
.- Specified by:
mulPosition
in interfaceVector2dc
- Parameters:
mat
- the matrix to multiply this vector bydest
- will hold the result- Returns:
- dest
-
mulDirection
Multiply the given 3x2 matrixmat
withthis
.This method assumes the
z
component ofthis
to be0.0
.- Parameters:
mat
- the matrix to multiply this vector by- Returns:
- this
-
mulDirection
Description copied from interface:Vector2dc
Multiply the given 3x2 matrixmat
withthis
and store the result indest
.This method assumes the
z
component ofthis
to be0.0
.- Specified by:
mulDirection
in interfaceVector2dc
- Parameters:
mat
- the matrix to multiply this vector bydest
- will hold the result- Returns:
- dest
-
dot
Description copied from interface:Vector2dc
Return the dot product of this vector andv
. -
angle
Description copied from interface:Vector2dc
Return the angle between this vector and the supplied vector. -
lengthSquared
public double lengthSquared()Description copied from interface:Vector2dc
Return the length squared of this vector.- Specified by:
lengthSquared
in interfaceVector2dc
- Returns:
- the length squared
-
lengthSquared
public static double lengthSquared(double x, double y) Get the length squared of a 2-dimensional double-precision vector.- Parameters:
x
- The vector's x componenty
- The vector's y component- Returns:
- the length squared of the given vector
-
length
public double length()Description copied from interface:Vector2dc
Return the length of this vector. -
length
public static double length(double x, double y) Get the length of a 2-dimensional double-precision vector.- Parameters:
x
- The vector's x componenty
- The vector's y component- Returns:
- the length of the given vector
-
distance
Description copied from interface:Vector2dc
Return the distance between this andv
. -
distanceSquared
Description copied from interface:Vector2dc
Return the distance squared between this andv
.- Specified by:
distanceSquared
in interfaceVector2dc
- Parameters:
v
- the other vector- Returns:
- the distance squared
-
distance
Description copied from interface:Vector2dc
Return the distance between this andv
. -
distanceSquared
Description copied from interface:Vector2dc
Return the distance squared between this andv
.- Specified by:
distanceSquared
in interfaceVector2dc
- Parameters:
v
- the other vector- Returns:
- the distance squared
-
distance
public double distance(double x, double y) Description copied from interface:Vector2dc
Return the distance betweenthis
vector and(x, y)
. -
distanceSquared
public double distanceSquared(double x, double y) Description copied from interface:Vector2dc
Return the distance squared betweenthis
vector and(x, y)
.- Specified by:
distanceSquared
in interfaceVector2dc
- Parameters:
x
- the x component of the other vectory
- the y component of the other vector- Returns:
- the euclidean distance squared
-
distance
public static double distance(double x1, double y1, double x2, double y2) Return the distance between(x1, y1)
and(x2, y2)
.- Parameters:
x1
- the x component of the first vectory1
- the y component of the first vectorx2
- the x component of the second vectory2
- the y component of the second vector- Returns:
- the euclidean distance
-
distanceSquared
public static double distanceSquared(double x1, double y1, double x2, double y2) Return the squared distance between(x1, y1)
and(x2, y2)
.- Parameters:
x1
- the x component of the first vectory1
- the y component of the first vectorx2
- the x component of the second vectory2
- the y component of the second vector- Returns:
- the euclidean distance squared
-
normalize
Normalize this vector.- Returns:
- this
-
normalize
Description copied from interface:Vector2dc
Normalize this vector and store the result indest
. -
normalize
Scale this vector to have the given length.- Parameters:
length
- the desired length- Returns:
- this
-
normalize
Description copied from interface:Vector2dc
Scale this vector to have the given length and store the result indest
. -
add
Addv
to this vector.- Parameters:
v
- the vector to add- Returns:
- this
-
add
Add(x, y)
to this vector.- Parameters:
x
- the x component to addy
- the y component to add- Returns:
- this
-
add
Description copied from interface:Vector2dc
Add(x, y)
to this vector and store the result indest
. -
add
Addv
to this vector.- Parameters:
v
- the vector to add- Returns:
- this
-
add
Description copied from interface:Vector2dc
Addv
to this vector and store the result indest
. -
add
Description copied from interface:Vector2dc
Addv
to this vector and store the result indest
. -
zero
Set all components to zero.- Returns:
- this
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-
negate
Negate this vector.- Returns:
- this
-
negate
Description copied from interface:Vector2dc
Negate this vector and store the result indest
. -
lerp
Linearly interpolatethis
andother
using the given interpolation factort
and store the result inthis
.If
t
is0.0
then the result isthis
. If the interpolation factor is1.0
then the result isother
.- Parameters:
other
- the other vectort
- the interpolation factor between 0.0 and 1.0- Returns:
- this
-
lerp
Description copied from interface:Vector2dc
Linearly interpolatethis
andother
using the given interpolation factort
and store the result indest
.If
t
is0.0
then the result isthis
. If the interpolation factor is1.0
then the result isother
. -
hashCode
public int hashCode() -
equals
-
equals
Description copied from interface:Vector2dc
Compare the vector components ofthis
vector with the given vector using the givendelta
and return whether all of them are equal within a maximum difference ofdelta
.Please note that this method is not used by any data structure such as
ArrayList
HashSet
orHashMap
and their operations, such asArrayList.contains(Object)
orHashSet.remove(Object)
, since those data structures only use theObject.equals(Object)
andObject.hashCode()
methods. -
equals
public boolean equals(double x, double y) Description copied from interface:Vector2dc
Compare the vector components ofthis
vector with the given(x, y)
and return whether all of them are equal. -
toString
Return a string representation of this vector.This method creates a new
DecimalFormat
on every invocation with the format string "0.000E0;-
". -
toString
Return a string representation of this vector by formatting the vector components with the givenNumberFormat
.- Parameters:
formatter
- theNumberFormat
used to format the vector components with- Returns:
- the string representation
-
fma
Add the component-wise multiplication ofa * b
to this vector.- Parameters:
a
- the first multiplicandb
- the second multiplicand- Returns:
- this
-
fma
Add the component-wise multiplication ofa * b
to this vector.- Parameters:
a
- the first multiplicandb
- the second multiplicand- Returns:
- this
-
fma
Description copied from interface:Vector2dc
Add the component-wise multiplication ofa * b
to this vector and store the result indest
. -
fma
Description copied from interface:Vector2dc
Add the component-wise multiplication ofa * b
to this vector and store the result indest
. -
min
Set the components of this vector to be the component-wise minimum of this and the other vector.- Parameters:
v
- the other vector- Returns:
- this
-
min
Description copied from interface:Vector2dc
Set the components ofdest
to be the component-wise minimum of this and the other vector. -
max
Set the components of this vector to be the component-wise maximum of this and the other vector.- Parameters:
v
- the other vector- Returns:
- this
-
max
Description copied from interface:Vector2dc
Set the components ofdest
to be the component-wise maximum of this and the other vector. -
maxComponent
public int maxComponent()Description copied from interface:Vector2dc
Determine the component with the biggest absolute value.- Specified by:
maxComponent
in interfaceVector2dc
- Returns:
- the component index, within
[0..1]
-
minComponent
public int minComponent()Description copied from interface:Vector2dc
Determine the component with the smallest (towards zero) absolute value.- Specified by:
minComponent
in interfaceVector2dc
- Returns:
- the component index, within
[0..1]
-
floor
Set each component of this vector to the largest (closest to positive infinity)double
value that is less than or equal to that component and is equal to a mathematical integer.- Returns:
- this
-
floor
Description copied from interface:Vector2dc
Compute for each component of this vector the largest (closest to positive infinity)double
value that is less than or equal to that component and is equal to a mathematical integer and store the result indest
. -
ceil
Set each component of this vector to the smallest (closest to negative infinity)double
value that is greater than or equal to that component and is equal to a mathematical integer.- Returns:
- this
-
ceil
Description copied from interface:Vector2dc
Compute for each component of this vector the smallest (closest to negative infinity)double
value that is greater than or equal to that component and is equal to a mathematical integer and store the result indest
. -
round
Set each component of this vector to the closest double that is equal to a mathematical integer, with ties rounding to positive infinity.- Returns:
- this
-
round
Description copied from interface:Vector2dc
Compute for each component of this vector the closest double that is equal to a mathematical integer, with ties rounding to positive infinity and store the result indest
. -
isFinite
public boolean isFinite()Description copied from interface:Vector2dc
-
absolute
Setthis
vector's components to their respective absolute values.- Returns:
- this
-
absolute
Description copied from interface:Vector2dc
Compute the absolute of each of this vector's components and store the result intodest
. -
clone
- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-