Class Vector2d
- java.lang.Object
-
- org.joml.Vector2d
-
- All Implemented Interfaces:
java.io.Externalizable,java.io.Serializable,java.lang.Cloneable,Vector2dc
public class Vector2d extends java.lang.Object implements java.io.Externalizable, java.lang.Cloneable, Vector2dc
Represents a 2D vector with double-precision.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Vector2d()Create a newVector2dand initialize its components to zero.Vector2d(double d)Create a newVector2dand initialize both of its components with the given value.Vector2d(double[] xy)Create a newVector2dand initialize its two components from the first two elements of the given array.Vector2d(double x, double y)Create a newVector2dand initialize its components to the given values.Vector2d(float[] xy)Create a newVector2dand initialize its two components from the first two elements of the given array.Vector2d(int index, java.nio.ByteBuffer buffer)Create a newVector2dand read this vector from the suppliedByteBufferstarting at the specified absolute buffer position/index.Vector2d(int index, java.nio.DoubleBuffer buffer)Create a newVector2dand read this vector from the suppliedDoubleBufferstarting at the specified absolute buffer position/index.Vector2d(java.nio.ByteBuffer buffer)Create a newVector2dand read this vector from the suppliedByteBufferat the current bufferposition.Vector2d(java.nio.DoubleBuffer buffer)Create a newVector2dand read this vector from the suppliedDoubleBufferat the current bufferposition.Vector2d(Vector2dc v)Create a newVector2dand initialize its components to the one of the given vector.Vector2d(Vector2fc v)Create a newVector2dand initialize its components to the one of the given vector.Vector2d(Vector2ic v)Create a newVector2dand initialize its components to the one of the given vector.Vector2d(Vector3dc v)Create a newVector2dand initialize its components using thexandycomponents of the provided vector.Vector2d(Vector3fc v)Create a newVector2dand initialize its components using thexandycomponents of the provided vector.Vector2d(Vector3ic v)Create a newVector2dand initialize its components using thexandycomponents of the provided vector.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Vector2dabsolute()Setthisvector's components to their respective absolute values.Vector2dabsolute(Vector2d dest)Compute the absolute of each of this vector's components and store the result intodest.Vector2dadd(double x, double y)Add(x, y)to this vector.Vector2dadd(double x, double y, Vector2d dest)Add(x, y)to this vector and store the result indest.Vector2dadd(Vector2dc v)Addvto this vector.Vector2dadd(Vector2dc v, Vector2d dest)Addvto this vector and store the result indest.Vector2dadd(Vector2fc v)Addvto this vector.Vector2dadd(Vector2fc v, Vector2d dest)Addvto this vector and store the result indest.doubleangle(Vector2dc v)Return the angle between this vector and the supplied vector.Vector2dceil()Set each component of this vector to the smallest (closest to negative infinity)doublevalue that is greater than or equal to that component and is equal to a mathematical integer.Vector2dceil(Vector2d dest)Compute for each component of this vector the smallest (closest to negative infinity)doublevalue that is greater than or equal to that component and is equal to a mathematical integer and store the result indest.java.lang.Objectclone()doubledistance(double x, double y)Return the distance betweenthisvector and(x, y).static doubledistance(double x1, double y1, double x2, double y2)Return the distance between(x1, y1)and(x2, y2).doubledistance(Vector2dc v)Return the distance between this andv.doubledistance(Vector2fc v)Return the distance between this andv.doubledistanceSquared(double x, double y)Return the distance squared betweenthisvector and(x, y).static doubledistanceSquared(double x1, double y1, double x2, double y2)Return the squared distance between(x1, y1)and(x2, y2).doubledistanceSquared(Vector2dc v)Return the distance squared between this andv.doubledistanceSquared(Vector2fc v)Return the distance squared between this andv.Vector2ddiv(double scalar)Divide this vector by the given scalar value.Vector2ddiv(double x, double y)Divide the components of this vector by the given scalar values and store the result inthis.Vector2ddiv(double x, double y, Vector2d dest)Divide the components of this vector by the given scalar values and store the result indest.Vector2ddiv(double scalar, Vector2d dest)Divide this vector by the given scalar value and store the result indest.Vector2ddiv(Vector2dc v)Divide this vector component-wise by another vector.Vector2ddiv(Vector2dc v, Vector2d dest)Divide this byvcomponent-wise and store the result intodest.Vector2ddiv(Vector2fc v)Divide this vector component-wise by another Vector2fc.Vector2ddiv(Vector2fc v, Vector2d dest)Divide this vector component-wise by another vector and store the result indest.doubledot(Vector2dc v)Return the dot product of this vector andv.booleanequals(double x, double y)Compare the vector components ofthisvector with the given(x, y)and return whether all of them are equal.booleanequals(java.lang.Object obj)booleanequals(Vector2dc v, double delta)Compare the vector components ofthisvector with the given vector using the givendeltaand return whether all of them are equal within a maximum difference ofdelta.Vector2dfloor()Set each component of this vector to the largest (closest to positive infinity)doublevalue that is less than or equal to that component and is equal to a mathematical integer.Vector2dfloor(Vector2d dest)Compute for each component of this vector the largest (closest to positive infinity)doublevalue that is less than or equal to that component and is equal to a mathematical integer and store the result indest.Vector2dfma(double a, Vector2dc b)Add the component-wise multiplication ofa * bto this vector.Vector2dfma(double a, Vector2dc b, Vector2d dest)Add the component-wise multiplication ofa * bto this vector and store the result indest.Vector2dfma(Vector2dc a, Vector2dc b)Add the component-wise multiplication ofa * bto this vector.Vector2dfma(Vector2dc a, Vector2dc b, Vector2d dest)Add the component-wise multiplication ofa * bto this vector and store the result indest.doubleget(int component)Get the value of the specified component of this vector.java.nio.ByteBufferget(int index, java.nio.ByteBuffer buffer)Store this vector into the suppliedByteBufferstarting at the specified absolute buffer position/index.java.nio.DoubleBufferget(int index, java.nio.DoubleBuffer buffer)Store this vector into the suppliedDoubleBufferstarting at the specified absolute buffer position/index.Vector2iget(int mode, Vector2i dest)java.nio.ByteBufferget(java.nio.ByteBuffer buffer)Store this vector into the suppliedByteBufferat the current bufferposition.java.nio.DoubleBufferget(java.nio.DoubleBuffer buffer)Store this vector into the suppliedDoubleBufferat the current bufferposition.Vector2dget(Vector2d dest)Set the components of the given vectordestto those ofthisvector.Vector2fget(Vector2f dest)Set the components of the given vectordestto those ofthisvector.Vector2dcgetToAddress(long address)Store this vector at the given off-heap memory address.inthashCode()booleanisFinite()Determine whether all components are finite floating-point values, that is, they are notNaNand notinfinity.doublelength()Return the length of this vector.static doublelength(double x, double y)Get the length of a 2-dimensional double-precision vector.doublelengthSquared()Return the length squared of this vector.static doublelengthSquared(double x, double y)Get the length squared of a 2-dimensional double-precision vector.Vector2dlerp(Vector2dc other, double t)Linearly interpolatethisandotherusing the given interpolation factortand store the result inthis.Vector2dlerp(Vector2dc other, double t, Vector2d dest)Linearly interpolatethisandotherusing the given interpolation factortand store the result indest.Vector2dmax(Vector2dc v)Set the components of this vector to be the component-wise maximum of this and the other vector.Vector2dmax(Vector2dc v, Vector2d dest)Set the components ofdestto be the component-wise maximum of this and the other vector.intmaxComponent()Determine the component with the biggest absolute value.Vector2dmin(Vector2dc v)Set the components of this vector to be the component-wise minimum of this and the other vector.Vector2dmin(Vector2dc v, Vector2d dest)Set the components ofdestto be the component-wise minimum of this and the other vector.intminComponent()Determine the component with the smallest (towards zero) absolute value.Vector2dmul(double scalar)Multiply the components of this vector by the given scalar.Vector2dmul(double x, double y)Multiply the components of this vector by the given scalar values and store the result inthis.Vector2dmul(double x, double y, Vector2d dest)Multiply the components of this vector by the given scalar values and store the result indest.Vector2dmul(double scalar, Vector2d dest)Multiply the components of this vector by the given scalar and store the result indest.Vector2dmul(Matrix2dc mat)Multiply the given matrixmatwith this vector.Vector2dmul(Matrix2dc mat, Vector2d dest)Multiply the given matrixmatwiththisand store the result indest.Vector2dmul(Matrix2fc mat)Multiply the given matrixmatwith this vector.Vector2dmul(Matrix2fc mat, Vector2d dest)Multiply the given matrixmatwiththisand store the result indest.Vector2dmul(Vector2dc v)Multiply this vector component-wise by another vector.Vector2dmul(Vector2dc v, Vector2d dest)Multiply this vector component-wise by another vector and store the result indest.Vector2dmulDirection(Matrix3x2dc mat)Multiply the given 3x2 matrixmatwiththis.Vector2dmulDirection(Matrix3x2dc mat, Vector2d dest)Multiply the given 3x2 matrixmatwiththisand store the result indest.Vector2dmulPosition(Matrix3x2dc mat)Multiply the given 3x2 matrixmatwiththis.Vector2dmulPosition(Matrix3x2dc mat, Vector2d dest)Multiply the given 3x2 matrixmatwiththisand store the result indest.Vector2dmulTranspose(Matrix2dc mat)Multiply the transpose of the given matrix with this vector and store the result inthis.Vector2dmulTranspose(Matrix2dc mat, Vector2d dest)Multiply the transpose of the given matrix with this vector and store the result indest.Vector2dmulTranspose(Matrix2fc mat)Multiply the transpose of the given matrix with this vector and store the result inthis.Vector2dmulTranspose(Matrix2fc mat, Vector2d dest)Multiply the transpose of the given matrix with this vector and store the result indest.Vector2dnegate()Negate this vector.Vector2dnegate(Vector2d dest)Negate this vector and store the result indest.Vector2dnormalize()Normalize this vector.Vector2dnormalize(double length)Scale this vector to have the given length.Vector2dnormalize(double length, Vector2d dest)Scale this vector to have the given length and store the result indest.Vector2dnormalize(Vector2d dest)Normalize this vector and store the result indest.Vector2dperpendicular()Set this vector to be one of its perpendicular vectors.voidreadExternal(java.io.ObjectInput in)Vector2dround()Set each component of this vector to the closest double that is equal to a mathematical integer, with ties rounding to positive infinity.Vector2dround(Vector2d dest)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.Vector2dset(double d)Set the x and y components to the supplied value.Vector2dset(double[] xy)Set the two components of this vector to the first two elements of the given array.Vector2dset(double x, double y)Set the x and y components to the supplied values.Vector2dset(float[] xy)Set the two components of this vector to the first two elements of the given array.Vector2dset(int index, java.nio.ByteBuffer buffer)Read this vector from the suppliedByteBufferstarting at the specified absolute buffer position/index.Vector2dset(int index, java.nio.DoubleBuffer buffer)Read this vector from the suppliedDoubleBufferstarting at the specified absolute buffer position/index.Vector2dset(java.nio.ByteBuffer buffer)Read this vector from the suppliedByteBufferat the current bufferposition.Vector2dset(java.nio.DoubleBuffer buffer)Read this vector from the suppliedDoubleBufferat the current bufferposition.Vector2dset(Vector2dc v)Set this vector to the values of v.Vector2dset(Vector2fc v)Set this vector to be a clone ofv.Vector2dset(Vector2ic v)Set this vector to be a clone ofv.Vector2dset(Vector3dc v)Set this vector to the(x, y)components ofv.Vector2dset(Vector3fc v)Set this vector to the(x, y)components ofv.Vector2dset(Vector3ic v)Set this vector to the(x, y)components ofv.Vector2dsetComponent(int component, double value)Set the value of the specified component of this vector.Vector2dsetFromAddress(long address)Set the values of this vector by reading 2 double values from off-heap memory, starting at the given address.Vector2dsub(double x, double y)Subtract(x, y)from this vector.Vector2dsub(double x, double y, Vector2d dest)Subtract(x, y)from this vector and store the result indest.Vector2dsub(Vector2dc v)Subtractvfrom this vector.Vector2dsub(Vector2dc v, Vector2d dest)Subtractvfromthisvector and store the result indest.Vector2dsub(Vector2fc v)Subtractvfrom this vector.Vector2dsub(Vector2fc v, Vector2d dest)Subtractvfromthisvector and store the result indest.java.lang.StringtoString()Return a string representation of this vector.java.lang.StringtoString(java.text.NumberFormat formatter)Return a string representation of this vector by formatting the vector components with the givenNumberFormat.voidwriteExternal(java.io.ObjectOutput out)doublex()doubley()Vector2dzero()Set all components to zero.
-
-
-
Constructor Detail
-
Vector2d
public Vector2d()
Create a newVector2dand initialize its components to zero.
-
Vector2d
public Vector2d(double d)
Create a newVector2dand 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 newVector2dand initialize its components to the given values.- Parameters:
x- the x valuey- the y value
-
Vector2d
public Vector2d(Vector2dc v)
Create a newVector2dand initialize its components to the one of the given vector.- Parameters:
v- theVector2dcto copy the values from
-
Vector2d
public Vector2d(Vector2fc v)
Create a newVector2dand initialize its components to the one of the given vector.- Parameters:
v- theVector2fcto copy the values from
-
Vector2d
public Vector2d(Vector2ic v)
Create a newVector2dand initialize its components to the one of the given vector.- Parameters:
v- theVector2icto copy the values from
-
Vector2d
public Vector2d(Vector3dc v)
Create a newVector2dand initialize its components using thexandycomponents of the provided vector.- Parameters:
v- theVector3dcto copy thexandycomponents from
-
Vector2d
public Vector2d(Vector3fc v)
Create a newVector2dand initialize its components using thexandycomponents of the provided vector.- Parameters:
v- theVector3fcto copy thexandycomponents from
-
Vector2d
public Vector2d(Vector3ic v)
Create a newVector2dand initialize its components using thexandycomponents of the provided vector.- Parameters:
v- theVector3icto copy thexandycomponents from
-
Vector2d
public Vector2d(double[] xy)
Create a newVector2dand 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 newVector2dand initialize its two components from the first two elements of the given array.- Parameters:
xy- the array containing at least two elements
-
Vector2d
public Vector2d(java.nio.ByteBuffer buffer)
Create a newVector2dand read this vector from the suppliedByteBufferat 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, yorder- See Also:
Vector2d(int, ByteBuffer)
-
Vector2d
public Vector2d(int index, java.nio.ByteBuffer buffer)Create a newVector2dand read this vector from the suppliedByteBufferstarting 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, yorder
-
Vector2d
public Vector2d(java.nio.DoubleBuffer buffer)
Create a newVector2dand read this vector from the suppliedDoubleBufferat 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, yorder- See Also:
Vector2d(int, DoubleBuffer)
-
Vector2d
public Vector2d(int index, java.nio.DoubleBuffer buffer)Create a newVector2dand read this vector from the suppliedDoubleBufferstarting 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, yorder
-
-
Method Detail
-
set
public Vector2d set(double d)
Set the x and y components to the supplied value.- Parameters:
d- the value of both components- Returns:
- this
-
set
public Vector2d set(double x, double y)
Set the x and y components to the supplied values.- Parameters:
x- the x valuey- the y value- Returns:
- this
-
set
public Vector2d set(Vector2dc v)
Set this vector to the values of v.- Parameters:
v- the vector to copy from- Returns:
- this
-
set
public Vector2d set(Vector2fc v)
Set this vector to be a clone ofv.- Parameters:
v- the vector to copy from- Returns:
- this
-
set
public Vector2d set(Vector2ic v)
Set this vector to be a clone ofv.- Parameters:
v- the vector to copy from- Returns:
- this
-
set
public Vector2d set(Vector3dc v)
Set this vector to the(x, y)components ofv.- Parameters:
v- the vector to copy from- Returns:
- this
-
set
public Vector2d set(Vector3fc v)
Set this vector to the(x, y)components ofv.- Parameters:
v- the vector to copy from- Returns:
- this
-
set
public Vector2d set(Vector3ic v)
Set this vector to the(x, y)components ofv.- Parameters:
v- the vector to copy from- Returns:
- this
-
set
public Vector2d set(double[] xy)
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
public Vector2d set(float[] xy)
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
public Vector2d set(java.nio.ByteBuffer buffer)
Read this vector from the suppliedByteBufferat 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, yorder- Returns:
- this
- See Also:
set(int, ByteBuffer)
-
set
public Vector2d set(int index, java.nio.ByteBuffer buffer)
Read this vector from the suppliedByteBufferstarting 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, yorder- Returns:
- this
-
set
public Vector2d set(java.nio.DoubleBuffer buffer)
Read this vector from the suppliedDoubleBufferat 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, yorder- Returns:
- this
- See Also:
set(int, DoubleBuffer)
-
set
public Vector2d set(int index, java.nio.DoubleBuffer buffer)
Read this vector from the suppliedDoubleBufferstarting 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, yorder- Returns:
- this
-
setFromAddress
public Vector2d setFromAddress(long address)
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
UnsupportedOperationExceptionwhen 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
public double get(int component) throws java.lang.IllegalArgumentExceptionDescription copied from interface:Vector2dcGet the value of the specified component of this vector.
-
get
public Vector2i get(int mode, Vector2i dest)
Description copied from interface:Vector2dc- Specified by:
getin interfaceVector2dc- Parameters:
mode- theRoundingModeto usedest- will hold the result- Returns:
- dest
-
get
public Vector2f get(Vector2f dest)
Description copied from interface:Vector2dcSet the components of the given vectordestto those ofthisvector.
-
get
public Vector2d get(Vector2d dest)
Description copied from interface:Vector2dcSet the components of the given vectordestto those ofthisvector.
-
setComponent
public Vector2d setComponent(int component, double value) throws java.lang.IllegalArgumentException
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:
java.lang.IllegalArgumentException- ifcomponentis not within[0..1]
-
get
public java.nio.ByteBuffer get(java.nio.ByteBuffer buffer)
Description copied from interface:Vector2dcStore this vector into the suppliedByteBufferat 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.- Specified by:
getin interfaceVector2dc- Parameters:
buffer- will receive the values of this vector inx, yorder- Returns:
- the passed in buffer
- See Also:
Vector2dc.get(int, ByteBuffer)
-
get
public java.nio.ByteBuffer get(int index, java.nio.ByteBuffer buffer)Description copied from interface:Vector2dcStore this vector into the suppliedByteBufferstarting at the specified absolute buffer position/index.This method will not increment the position of the given ByteBuffer.
-
get
public java.nio.DoubleBuffer get(java.nio.DoubleBuffer buffer)
Description copied from interface:Vector2dcStore this vector into the suppliedDoubleBufferat 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.- Specified by:
getin interfaceVector2dc- Parameters:
buffer- will receive the values of this vector inx, yorder- Returns:
- the passed in buffer
- See Also:
Vector2dc.get(int, DoubleBuffer)
-
get
public java.nio.DoubleBuffer get(int index, java.nio.DoubleBuffer buffer)Description copied from interface:Vector2dcStore this vector into the suppliedDoubleBufferstarting at the specified absolute buffer position/index.This method will not increment the position of the given DoubleBuffer.
-
getToAddress
public Vector2dc getToAddress(long address)
Description copied from interface:Vector2dcStore this vector at the given off-heap memory address.This method will throw an
UnsupportedOperationExceptionwhen 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:
getToAddressin interfaceVector2dc- Parameters:
address- the off-heap address where to store this vector- Returns:
- this
-
perpendicular
public Vector2d perpendicular()
Set this vector to be one of its perpendicular vectors.- Returns:
- this
-
sub
public Vector2d sub(Vector2dc v)
Subtractvfrom this vector.- Parameters:
v- the vector to subtract- Returns:
- this
-
sub
public Vector2d sub(double x, double y)
Subtract(x, y)from this vector.- Parameters:
x- the x component to subtracty- the y component to subtract- Returns:
- this
-
sub
public Vector2d sub(double x, double y, Vector2d dest)
Description copied from interface:Vector2dcSubtract(x, y)from this vector and store the result indest.
-
sub
public Vector2d sub(Vector2fc v)
Subtractvfrom this vector.- Parameters:
v- the vector to subtract- Returns:
- this
-
sub
public Vector2d sub(Vector2dc v, Vector2d dest)
Description copied from interface:Vector2dcSubtractvfromthisvector and store the result indest.
-
sub
public Vector2d sub(Vector2fc v, Vector2d dest)
Description copied from interface:Vector2dcSubtractvfromthisvector and store the result indest.
-
mul
public Vector2d mul(double scalar)
Multiply the components of this vector by the given scalar.- Parameters:
scalar- the value to multiply this vector's components by- Returns:
- this
-
mul
public Vector2d mul(double scalar, Vector2d dest)
Description copied from interface:Vector2dcMultiply the components of this vector by the given scalar and store the result indest.
-
mul
public Vector2d mul(double x, double y)
Multiply the components of this vector 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
public Vector2d mul(double x, double y, Vector2d dest)
Description copied from interface:Vector2dcMultiply the components of this vector by the given scalar values and store the result indest.
-
mul
public Vector2d mul(Vector2dc v)
Multiply this vector component-wise by another vector.- Parameters:
v- the vector to multiply by- Returns:
- this
-
mul
public Vector2d mul(Vector2dc v, Vector2d dest)
Description copied from interface:Vector2dcMultiply this vector component-wise by another vector and store the result indest.
-
div
public Vector2d div(double scalar)
Divide this vector by the given scalar value.- Parameters:
scalar- the scalar to divide this vector by- Returns:
- this
-
div
public Vector2d div(double scalar, Vector2d dest)
Description copied from interface:Vector2dcDivide this vector by the given scalar value and store the result indest.
-
div
public Vector2d div(double x, double y)
Divide the components of this vector 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
public Vector2d div(double x, double y, Vector2d dest)
Description copied from interface:Vector2dcDivide the components of this vector by the given scalar values and store the result indest.
-
div
public Vector2d div(Vector2dc v)
Divide this vector component-wise by another vector.- Parameters:
v- the vector to divide by- Returns:
- this
-
div
public Vector2d div(Vector2fc v)
Divide this vector component-wise by another Vector2fc.- Parameters:
v- the vector to divide by- Returns:
- this
-
div
public Vector2d div(Vector2fc v, Vector2d dest)
Description copied from interface:Vector2dcDivide this vector component-wise by another vector and store the result indest.
-
div
public Vector2d div(Vector2dc v, Vector2d dest)
Description copied from interface:Vector2dcDivide this byvcomponent-wise and store the result intodest.
-
mul
public Vector2d mul(Matrix2fc mat)
Multiply the given matrixmatwith this vector.- Parameters:
mat- the matrix to multiply this vector by- Returns:
- this
-
mul
public Vector2d mul(Matrix2dc mat)
Multiply the given matrixmatwith this vector.- Parameters:
mat- the matrix to multiply this vector by- Returns:
- this
-
mul
public Vector2d mul(Matrix2dc mat, Vector2d dest)
Description copied from interface:Vector2dcMultiply the given matrixmatwiththisand store the result indest.Note that this method performs the operation
M * this, whereMis the provided matrix and thus interpretsthisas a column vector.
-
mul
public Vector2d mul(Matrix2fc mat, Vector2d dest)
Description copied from interface:Vector2dcMultiply the given matrixmatwiththisand store the result indest.Note that this method performs the operation
M * this, whereMis the provided matrix and thus interpretsthisas a column vector.
-
mulTranspose
public Vector2d mulTranspose(Matrix2dc mat)
Multiply the transpose of the given matrix with this vector and store the result inthis.- Parameters:
mat- the matrix- Returns:
- this
-
mulTranspose
public Vector2d mulTranspose(Matrix2dc mat, Vector2d dest)
Description copied from interface:Vector2dcMultiply the transpose of the given matrix with this vector and store the result indest.Note that this method performs the operation
M^T * this, whereMis the provided matrix and thus interpretsthisas a column vector.- Specified by:
mulTransposein interfaceVector2dc- Parameters:
mat- the matrixdest- will hold the result- Returns:
- dest
-
mulTranspose
public Vector2d mulTranspose(Matrix2fc mat)
Multiply the transpose of the given matrix with this vector and store the result inthis.- Parameters:
mat- the matrix- Returns:
- this
-
mulTranspose
public Vector2d mulTranspose(Matrix2fc mat, Vector2d dest)
Description copied from interface:Vector2dcMultiply the transpose of the given matrix with this vector and store the result indest.Note that this method performs the operation
M^T * this, whereMis the provided matrix and thus interpretsthisas a column vector.- Specified by:
mulTransposein interfaceVector2dc- Parameters:
mat- the matrixdest- will hold the result- Returns:
- dest
-
mulPosition
public Vector2d mulPosition(Matrix3x2dc mat)
Multiply the given 3x2 matrixmatwiththis.This method assumes the
zcomponent ofthisto be1.0.- Parameters:
mat- the matrix to multiply this vector by- Returns:
- this
-
mulPosition
public Vector2d mulPosition(Matrix3x2dc mat, Vector2d dest)
Description copied from interface:Vector2dcMultiply the given 3x2 matrixmatwiththisand store the result indest.This method assumes the
zcomponent ofthisto be1.0.Note that this method performs the operation
M * this, whereMis the provided matrix and thus interpretsthisas a column vector.- Specified by:
mulPositionin interfaceVector2dc- Parameters:
mat- the matrix to multiply this vector bydest- will hold the result- Returns:
- dest
-
mulDirection
public Vector2d mulDirection(Matrix3x2dc mat)
Multiply the given 3x2 matrixmatwiththis.This method assumes the
zcomponent ofthisto be0.0.- Parameters:
mat- the matrix to multiply this vector by- Returns:
- this
-
mulDirection
public Vector2d mulDirection(Matrix3x2dc mat, Vector2d dest)
Description copied from interface:Vector2dcMultiply the given 3x2 matrixmatwiththisand store the result indest.This method assumes the
zcomponent ofthisto be0.0.Note that this method performs the operation
M * this, whereMis the provided matrix and thus interpretsthisas a column vector.- Specified by:
mulDirectionin interfaceVector2dc- Parameters:
mat- the matrix to multiply this vector bydest- will hold the result- Returns:
- dest
-
dot
public double dot(Vector2dc v)
Description copied from interface:Vector2dcReturn the dot product of this vector andv.
-
angle
public double angle(Vector2dc v)
Description copied from interface:Vector2dcReturn the angle between this vector and the supplied vector.
-
lengthSquared
public double lengthSquared()
Description copied from interface:Vector2dcReturn the length squared of this vector.- Specified by:
lengthSquaredin 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:Vector2dcReturn 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
public double distance(Vector2dc v)
Description copied from interface:Vector2dcReturn the distance between this andv.
-
distanceSquared
public double distanceSquared(Vector2dc v)
Description copied from interface:Vector2dcReturn the distance squared between this andv.- Specified by:
distanceSquaredin interfaceVector2dc- Parameters:
v- the other vector- Returns:
- the distance squared
-
distance
public double distance(Vector2fc v)
Description copied from interface:Vector2dcReturn the distance between this andv.
-
distanceSquared
public double distanceSquared(Vector2fc v)
Description copied from interface:Vector2dcReturn the distance squared between this andv.- Specified by:
distanceSquaredin interfaceVector2dc- Parameters:
v- the other vector- Returns:
- the distance squared
-
distance
public double distance(double x, double y)Description copied from interface:Vector2dcReturn the distance betweenthisvector and(x, y).
-
distanceSquared
public double distanceSquared(double x, double y)Description copied from interface:Vector2dcReturn the distance squared betweenthisvector and(x, y).- Specified by:
distanceSquaredin 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
public Vector2d normalize()
Normalize this vector.- Returns:
- this
-
normalize
public Vector2d normalize(Vector2d dest)
Description copied from interface:Vector2dcNormalize this vector and store the result indest.
-
normalize
public Vector2d normalize(double length)
Scale this vector to have the given length.- Parameters:
length- the desired length- Returns:
- this
-
normalize
public Vector2d normalize(double length, Vector2d dest)
Description copied from interface:Vector2dcScale this vector to have the given length and store the result indest.
-
add
public Vector2d add(Vector2dc v)
Addvto this vector.- Parameters:
v- the vector to add- Returns:
- this
-
add
public Vector2d add(double x, double y)
Add(x, y)to this vector.- Parameters:
x- the x component to addy- the y component to add- Returns:
- this
-
add
public Vector2d add(double x, double y, Vector2d dest)
Description copied from interface:Vector2dcAdd(x, y)to this vector and store the result indest.
-
add
public Vector2d add(Vector2fc v)
Addvto this vector.- Parameters:
v- the vector to add- Returns:
- this
-
add
public Vector2d add(Vector2dc v, Vector2d dest)
Description copied from interface:Vector2dcAddvto this vector and store the result indest.
-
add
public Vector2d add(Vector2fc v, Vector2d dest)
Description copied from interface:Vector2dcAddvto this vector and store the result indest.
-
zero
public Vector2d zero()
Set all components to zero.- Returns:
- this
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException- Specified by:
writeExternalin interfacejava.io.Externalizable- Throws:
java.io.IOException
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException- Specified by:
readExternalin interfacejava.io.Externalizable- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
negate
public Vector2d negate()
Negate this vector.- Returns:
- this
-
negate
public Vector2d negate(Vector2d dest)
Description copied from interface:Vector2dcNegate this vector and store the result indest.
-
lerp
public Vector2d lerp(Vector2dc other, double t)
Linearly interpolatethisandotherusing the given interpolation factortand store the result inthis.If
tis0.0then the result isthis. If the interpolation factor is1.0then the result isother.- Parameters:
other- the other vectort- the interpolation factor between 0.0 and 1.0- Returns:
- this
-
lerp
public Vector2d lerp(Vector2dc other, double t, Vector2d dest)
Description copied from interface:Vector2dcLinearly interpolatethisandotherusing the given interpolation factortand store the result indest.If
tis0.0then the result isthis. If the interpolation factor is1.0then the result isother.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
equals
public boolean equals(Vector2dc v, double delta)
Description copied from interface:Vector2dcCompare the vector components ofthisvector with the given vector using the givendeltaand 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
ArrayListHashSetorHashMapand 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:Vector2dcCompare the vector components ofthisvector with the given(x, y)and return whether all of them are equal.
-
toString
public java.lang.String toString()
Return a string representation of this vector.This method creates a new
DecimalFormaton every invocation with the format string "0.000E0;-".- Overrides:
toStringin classjava.lang.Object- Returns:
- the string representation
-
toString
public java.lang.String toString(java.text.NumberFormat formatter)
Return a string representation of this vector by formatting the vector components with the givenNumberFormat.- Parameters:
formatter- theNumberFormatused to format the vector components with- Returns:
- the string representation
-
fma
public Vector2d fma(Vector2dc a, Vector2dc b)
Add the component-wise multiplication ofa * bto this vector.- Parameters:
a- the first multiplicandb- the second multiplicand- Returns:
- this
-
fma
public Vector2d fma(double a, Vector2dc b)
Add the component-wise multiplication ofa * bto this vector.- Parameters:
a- the first multiplicandb- the second multiplicand- Returns:
- this
-
fma
public Vector2d fma(Vector2dc a, Vector2dc b, Vector2d dest)
Description copied from interface:Vector2dcAdd the component-wise multiplication ofa * bto this vector and store the result indest.
-
fma
public Vector2d fma(double a, Vector2dc b, Vector2d dest)
Description copied from interface:Vector2dcAdd the component-wise multiplication ofa * bto this vector and store the result indest.
-
min
public Vector2d min(Vector2dc v)
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
public Vector2d min(Vector2dc v, Vector2d dest)
Description copied from interface:Vector2dcSet the components ofdestto be the component-wise minimum of this and the other vector.
-
max
public Vector2d max(Vector2dc v)
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
public Vector2d max(Vector2dc v, Vector2d dest)
Description copied from interface:Vector2dcSet the components ofdestto be the component-wise maximum of this and the other vector.
-
maxComponent
public int maxComponent()
Description copied from interface:Vector2dcDetermine the component with the biggest absolute value.- Specified by:
maxComponentin interfaceVector2dc- Returns:
- the component index, within
[0..1]
-
minComponent
public int minComponent()
Description copied from interface:Vector2dcDetermine the component with the smallest (towards zero) absolute value.- Specified by:
minComponentin interfaceVector2dc- Returns:
- the component index, within
[0..1]
-
floor
public Vector2d floor()
Set each component of this vector to the largest (closest to positive infinity)doublevalue that is less than or equal to that component and is equal to a mathematical integer.- Returns:
- this
-
floor
public Vector2d floor(Vector2d dest)
Description copied from interface:Vector2dcCompute for each component of this vector the largest (closest to positive infinity)doublevalue that is less than or equal to that component and is equal to a mathematical integer and store the result indest.
-
ceil
public Vector2d ceil()
Set each component of this vector to the smallest (closest to negative infinity)doublevalue that is greater than or equal to that component and is equal to a mathematical integer.- Returns:
- this
-
ceil
public Vector2d ceil(Vector2d dest)
Description copied from interface:Vector2dcCompute for each component of this vector the smallest (closest to negative infinity)doublevalue that is greater than or equal to that component and is equal to a mathematical integer and store the result indest.
-
round
public Vector2d 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
public Vector2d round(Vector2d dest)
Description copied from interface:Vector2dcCompute 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:Vector2dcDetermine whether all components are finite floating-point values, that is, they are notNaNand notinfinity.
-
absolute
public Vector2d absolute()
Setthisvector's components to their respective absolute values.- Returns:
- this
-
absolute
public Vector2d absolute(Vector2d dest)
Description copied from interface:Vector2dcCompute the absolute of each of this vector's components and store the result intodest.
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException- Overrides:
clonein classjava.lang.Object- Throws:
java.lang.CloneNotSupportedException
-
-