Class Vector2f
- java.lang.Object
-
- org.joml.Vector2f
-
- All Implemented Interfaces:
java.io.Externalizable,java.io.Serializable,java.lang.Cloneable,Vector2fc
public class Vector2f extends java.lang.Object implements java.io.Externalizable, java.lang.Cloneable, Vector2fc
Represents a 2D vector with single-precision.- Author:
- RGreenlees, Kai Burjack, F. Neurath
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Vector2f()Create a newVector2fand initialize its components to zero.Vector2f(float d)Create a newVector2fand initialize both of its components with the given value.Vector2f(float[] xy)Create a newVector2fand initialize its two components from the first two elements of the given array.Vector2f(float x, float y)Create a newVector2fand initialize its components to the given values.Vector2f(int index, java.nio.ByteBuffer buffer)Create a newVector2fand read this vector from the suppliedByteBufferstarting at the specified absolute buffer position/index.Vector2f(int index, java.nio.FloatBuffer buffer)Create a newVector2fand read this vector from the suppliedFloatBufferstarting at the specified absolute buffer position/index.Vector2f(java.nio.ByteBuffer buffer)Create a newVector2fand read this vector from the suppliedByteBufferat the current bufferposition.Vector2f(java.nio.FloatBuffer buffer)Create a newVector2fand read this vector from the suppliedFloatBufferat the current bufferposition.Vector2f(Vector2fc v)Create a newVector2fand initialize its components to the one of the given vector.Vector2f(Vector2ic v)Create a newVector2fand initialize its components to the one of the given vector.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Vector2fabsolute()Setthisvector's components to their respective absolute values.Vector2fabsolute(Vector2f dest)Compute the absolute of each of this vector's components and store the result intodest.Vector2fadd(float x, float y)Increment the components of this vector by the given values.Vector2fadd(float x, float y, Vector2f dest)Increment the components of this vector by the given values and store the result indest.Vector2fadd(Vector2fc v)Addvto this vector.Vector2fadd(Vector2fc v, Vector2f dest)Add the supplied vector to this one and store the result indest.floatangle(Vector2fc v)Return the angle between this vector and the supplied vector.Vector2fceil()Ceil each component of this vectorVector2fceil(Vector2f dest)Compute for each component of this vector the smallest (closest to negative infinity)floatvalue that is greater than or equal to that component and is equal to a mathematical integer and store the result indest.java.lang.Objectclone()floatdistance(float x, float y)Return the distance betweenthisvector and(x, y).static floatdistance(float x1, float y1, float x2, float y2)Return the distance between(x1, y1)and(x2, y2).floatdistance(Vector2fc v)Return the distance between this andv.floatdistanceSquared(float x, float y)Return the distance squared betweenthisvector and(x, y).static floatdistanceSquared(float x1, float y1, float x2, float y2)Return the squared distance between(x1, y1)and(x2, y2).floatdistanceSquared(Vector2fc v)Return the distance squared between this andv.Vector2fdiv(float scalar)Divide all components of thisVector2fby the given scalar value.Vector2fdiv(float x, float y)Divide the components of this Vector2f by the given scalar values and store the result inthis.Vector2fdiv(float x, float y, Vector2f dest)Divide the components of this Vector2f by the given scalar values and store the result indest.Vector2fdiv(float scalar, Vector2f dest)Divide all components of thisVector2fby the given scalar value and store the result indest.Vector2fdiv(Vector2fc v)Divide this Vector2f component-wise by another Vector2fc.Vector2fdiv(Vector2fc v, Vector2f dest)Divide this Vector2f component-wise by another Vector2fc and store the result indest.floatdot(Vector2fc v)Return the dot product of this vector andv.booleanequals(float x, float 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(Vector2fc v, float 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.Vector2ffloor()Set each component of this vector to the largest (closest to positive infinity)floatvalue that is less than or equal to that component and is equal to a mathematical integer.Vector2ffloor(Vector2f dest)Compute for each component of this vector the largest (closest to positive infinity)floatvalue that is less than or equal to that component and is equal to a mathematical integer and store the result indest.Vector2ffma(float a, Vector2fc b)Add the component-wise multiplication ofa * bto this vector.Vector2ffma(float a, Vector2fc b, Vector2f dest)Add the component-wise multiplication ofa * bto this vector and store the result indest.Vector2ffma(Vector2fc a, Vector2fc b)Add the component-wise multiplication ofa * bto this vector.Vector2ffma(Vector2fc a, Vector2fc b, Vector2f dest)Add the component-wise multiplication ofa * bto this vector and store the result indest.floatget(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.FloatBufferget(int index, java.nio.FloatBuffer buffer)Store this vector into the suppliedFloatBufferstarting 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.FloatBufferget(java.nio.FloatBuffer buffer)Store this vector into the suppliedFloatBufferat 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.Vector2fcgetToAddress(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.floatlength()Return the length of this vector.static floatlength(float x, float y)Get the length of a 2-dimensional single-precision vector.floatlengthSquared()Return the length squared of this vector.static floatlengthSquared(float x, float y)Get the length squared of a 2-dimensional single-precision vector.Vector2flerp(Vector2fc other, float t)Linearly interpolatethisandotherusing the given interpolation factortand store the result inthis.Vector2flerp(Vector2fc other, float t, Vector2f dest)Linearly interpolatethisandotherusing the given interpolation factortand store the result indest.Vector2fmax(Vector2fc v)Set the components of this vector to be the component-wise maximum of this and the other vector.Vector2fmax(Vector2fc v, Vector2f 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.Vector2fmin(Vector2fc v)Set the components of this vector to be the component-wise minimum of this and the other vector.Vector2fmin(Vector2fc v, Vector2f 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.Vector2fmul(float scalar)Multiply the components of this vector by the given scalar.Vector2fmul(float x, float y)Multiply the components of this Vector2f by the given scalar values and store the result inthis.Vector2fmul(float x, float y, Vector2f dest)Multiply the components of this Vector2f by the given scalar values and store the result indest.Vector2fmul(float scalar, Vector2f dest)Multiply the components of this vector by the given scalar and store the result indest.Vector2fmul(Matrix2dc mat)Multiply the given matrix with this Vector2f and store the result inthis.Vector2fmul(Matrix2dc mat, Vector2f dest)Multiply the given matrix with this Vector2f and store the result indest.Vector2fmul(Matrix2fc mat)Multiply the given matrix with this Vector2f and store the result inthis.Vector2fmul(Matrix2fc mat, Vector2f dest)Multiply the given matrix with this Vector2f and store the result indest.Vector2fmul(Vector2fc v)Multiply this Vector2f component-wise by another Vector2f.Vector2fmul(Vector2fc v, Vector2f dest)Multiply this Vector2f component-wise by another Vector2f and store the result indest.Vector2fmulDirection(Matrix3x2fc mat)Multiply the given 3x2 matrixmatwiththis.Vector2fmulDirection(Matrix3x2fc mat, Vector2f dest)Multiply the given 3x2 matrixmatwiththisand store the result indest.Vector2fmulPosition(Matrix3x2fc mat)Multiply the given 3x2 matrixmatwiththis.Vector2fmulPosition(Matrix3x2fc mat, Vector2f dest)Multiply the given 3x2 matrixmatwiththisand store the result indest.Vector2fmulTranspose(Matrix2fc mat)Multiply the transpose of the given matrix with this Vector2f store the result inthis.Vector2fmulTranspose(Matrix2fc mat, Vector2f dest)Multiply the transpose of the given matrix with this Vector3f and store the result indest.Vector2fnegate()Negate this vector.Vector2fnegate(Vector2f dest)Negate this vector and store the result indest.Vector2fnormalize()Normalize this vector.Vector2fnormalize(float length)Scale this vector to have the given length.Vector2fnormalize(float length, Vector2f dest)Scale this vector to have the given length and store the result indest.Vector2fnormalize(Vector2f dest)Normalize this vector and store the result indest.Vector2fperpendicular()Set this vector to be one of its perpendicular vectors.voidreadExternal(java.io.ObjectInput in)Vector2fround()Set each component of this vector to the closest float that is equal to a mathematical integer, with ties rounding to positive infinity.Vector2fround(Vector2f dest)Compute for each component of this vector the closest float that is equal to a mathematical integer, with ties rounding to positive infinity and store the result indest.Vector2fset(double d)Set the x and y components to the supplied value.Vector2fset(double x, double y)Set the x and y components to the supplied values.Vector2fset(float d)Set the x and y components to the supplied value.Vector2fset(float[] xy)Set the two components of this vector to the first two elements of the given array.Vector2fset(float x, float y)Set the x and y components to the supplied values.Vector2fset(int index, java.nio.ByteBuffer buffer)Read this vector from the suppliedByteBufferstarting at the specified absolute buffer position/index.Vector2fset(int index, java.nio.FloatBuffer buffer)Read this vector from the suppliedFloatBufferstarting at the specified absolute buffer position/index.Vector2fset(java.nio.ByteBuffer buffer)Read this vector from the suppliedByteBufferat the current bufferposition.Vector2fset(java.nio.FloatBuffer buffer)Read this vector from the suppliedFloatBufferat the current bufferposition.Vector2fset(Vector2dc v)Set thisVector2fto the values of v.Vector2fset(Vector2fc v)Set thisVector2fto the values of v.Vector2fset(Vector2ic v)Set thisVector2fto the values of v.Vector2fsetComponent(int component, float value)Set the value of the specified component of this vector.Vector2fsetFromAddress(long address)Set the values of this vector by reading 2 float values from off-heap memory, starting at the given address.Vector2fsub(float x, float y)Subtract(x, y)from this vector.Vector2fsub(float x, float y, Vector2f dest)Subtract(x, y)from this vector and store the result indest.Vector2fsub(Vector2fc v)Subtractvfrom this vector.Vector2fsub(Vector2fc v, Vector2f 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)floatx()floaty()Vector2fzero()Set all components to zero.
-
-
-
Constructor Detail
-
Vector2f
public Vector2f()
Create a newVector2fand initialize its components to zero.
-
Vector2f
public Vector2f(float d)
Create a newVector2fand initialize both of its components with the given value.- Parameters:
d- the value of both components
-
Vector2f
public Vector2f(float x, float y)Create a newVector2fand initialize its components to the given values.- Parameters:
x- the x componenty- the y component
-
Vector2f
public Vector2f(Vector2fc v)
Create a newVector2fand initialize its components to the one of the given vector.- Parameters:
v- theVector2fcto copy the values from
-
Vector2f
public Vector2f(Vector2ic v)
Create a newVector2fand initialize its components to the one of the given vector.- Parameters:
v- theVector2icto copy the values from
-
Vector2f
public Vector2f(float[] xy)
Create a newVector2fand initialize its two components from the first two elements of the given array.- Parameters:
xy- the array containing at least two elements
-
Vector2f
public Vector2f(java.nio.ByteBuffer buffer)
Create a newVector2fand 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
Vector2f(int, ByteBuffer), taking the absolute position as parameter.- Parameters:
buffer- values will be read inx, yorder- See Also:
Vector2f(int, ByteBuffer)
-
Vector2f
public Vector2f(int index, java.nio.ByteBuffer buffer)Create a newVector2fand 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
-
Vector2f
public Vector2f(java.nio.FloatBuffer buffer)
Create a newVector2fand read this vector from the suppliedFloatBufferat the current bufferposition.This method will not increment the position of the given FloatBuffer.
In order to specify the offset into the FloatBuffer at which the vector is read, use
Vector2f(int, FloatBuffer), taking the absolute position as parameter.- Parameters:
buffer- values will be read inx, yorder- See Also:
Vector2f(int, FloatBuffer)
-
Vector2f
public Vector2f(int index, java.nio.FloatBuffer buffer)Create a newVector2fand read this vector from the suppliedFloatBufferstarting at the specified absolute buffer position/index.This method will not increment the position of the given FloatBuffer.
- Parameters:
index- the absolute position into the FloatBufferbuffer- values will be read inx, yorder
-
-
Method Detail
-
set
public Vector2f set(float d)
Set the x and y components to the supplied value.- Parameters:
d- the value of both components- Returns:
- this
-
set
public Vector2f set(float x, float y)
Set the x and y components to the supplied values.- Parameters:
x- the x componenty- the y component- Returns:
- this
-
set
public Vector2f set(double d)
Set the x and y components to the supplied value.- Parameters:
d- the value of both components- Returns:
- this
-
set
public Vector2f set(double x, double y)
Set the x and y components to the supplied values.- Parameters:
x- the x componenty- the y component- Returns:
- this
-
set
public Vector2f set(Vector2fc v)
Set thisVector2fto the values of v.- Parameters:
v- the vector to copy from- Returns:
- this
-
set
public Vector2f set(Vector2ic v)
Set thisVector2fto the values of v.- Parameters:
v- the vector to copy from- Returns:
- this
-
set
public Vector2f set(Vector2dc v)
Set thisVector2fto the values of v.Note that due to the given vector
vstoring the components in double-precision, there is the possibility to lose precision.- Parameters:
v- the vector to copy from- Returns:
- this
-
set
public Vector2f 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 Vector2f 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 Vector2f 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 Vector2f set(java.nio.FloatBuffer buffer)
Read this vector from the suppliedFloatBufferat the current bufferposition.This method will not increment the position of the given FloatBuffer.
In order to specify the offset into the FloatBuffer at which the vector is read, use
set(int, FloatBuffer), taking the absolute position as parameter.- Parameters:
buffer- values will be read inx, yorder- Returns:
- this
- See Also:
set(int, FloatBuffer)
-
set
public Vector2f set(int index, java.nio.FloatBuffer buffer)
Read this vector from the suppliedFloatBufferstarting at the specified absolute buffer position/index.This method will not increment the position of the given FloatBuffer.
- Parameters:
index- the absolute position into the FloatBufferbuffer- values will be read inx, yorder- Returns:
- this
-
setFromAddress
public Vector2f setFromAddress(long address)
Set the values of this vector by reading 2 float 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 float get(int component) throws java.lang.IllegalArgumentExceptionDescription copied from interface:Vector2fcGet the value of the specified component of this vector.
-
get
public Vector2i get(int mode, Vector2i dest)
Description copied from interface:Vector2fc- Specified by:
getin interfaceVector2fc- Parameters:
mode- theRoundingModeto usedest- will hold the result- Returns:
- dest
-
get
public Vector2f get(Vector2f dest)
Description copied from interface:Vector2fcSet the components of the given vectordestto those ofthisvector.
-
get
public Vector2d get(Vector2d dest)
Description copied from interface:Vector2fcSet the components of the given vectordestto those ofthisvector.
-
setComponent
public Vector2f setComponent(int component, float 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:Vector2fcStore 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
Vector2fc.get(int, ByteBuffer), taking the absolute position as parameter.- Specified by:
getin interfaceVector2fc- Parameters:
buffer- will receive the values of this vector inx, yorder- Returns:
- the passed in buffer
- See Also:
Vector2fc.get(int, ByteBuffer)
-
get
public java.nio.ByteBuffer get(int index, java.nio.ByteBuffer buffer)Description copied from interface:Vector2fcStore 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.FloatBuffer get(java.nio.FloatBuffer buffer)
Description copied from interface:Vector2fcStore this vector into the suppliedFloatBufferat the current bufferposition.This method will not increment the position of the given FloatBuffer.
In order to specify the offset into the FloatBuffer at which the vector is stored, use
Vector2fc.get(int, FloatBuffer), taking the absolute position as parameter.- Specified by:
getin interfaceVector2fc- Parameters:
buffer- will receive the values of this vector inx, yorder- Returns:
- the passed in buffer
- See Also:
Vector2fc.get(int, FloatBuffer)
-
get
public java.nio.FloatBuffer get(int index, java.nio.FloatBuffer buffer)Description copied from interface:Vector2fcStore this vector into the suppliedFloatBufferstarting at the specified absolute buffer position/index.This method will not increment the position of the given FloatBuffer.
-
getToAddress
public Vector2fc getToAddress(long address)
Description copied from interface:Vector2fcStore 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 interfaceVector2fc- Parameters:
address- the off-heap address where to store this vector- Returns:
- this
-
perpendicular
public Vector2f perpendicular()
Set this vector to be one of its perpendicular vectors.- Returns:
- this
-
sub
public Vector2f sub(Vector2fc v)
Subtractvfrom this vector.- Parameters:
v- the vector to subtract- Returns:
- this
-
sub
public Vector2f sub(Vector2fc v, Vector2f dest)
Description copied from interface:Vector2fcSubtractvfromthisvector and store the result indest.
-
sub
public Vector2f sub(float x, float y)
Subtract(x, y)from this vector.- Parameters:
x- the x component to subtracty- the y component to subtract- Returns:
- this
-
sub
public Vector2f sub(float x, float y, Vector2f dest)
Description copied from interface:Vector2fcSubtract(x, y)from this vector and store the result indest.
-
dot
public float dot(Vector2fc v)
Description copied from interface:Vector2fcReturn the dot product of this vector andv.
-
angle
public float angle(Vector2fc v)
Description copied from interface:Vector2fcReturn the angle between this vector and the supplied vector.
-
lengthSquared
public float lengthSquared()
Description copied from interface:Vector2fcReturn the length squared of this vector.- Specified by:
lengthSquaredin interfaceVector2fc- Returns:
- the length squared
-
lengthSquared
public static float lengthSquared(float x, float y)Get the length squared of a 2-dimensional single-precision vector.- Parameters:
x- The vector's x componenty- The vector's y component- Returns:
- the length squared of the given vector
-
length
public float length()
Description copied from interface:Vector2fcReturn the length of this vector.
-
length
public static float length(float x, float y)Get the length of a 2-dimensional single-precision vector.- Parameters:
x- The vector's x componenty- The vector's y component- Returns:
- the length of the given vector
-
distance
public float distance(Vector2fc v)
Description copied from interface:Vector2fcReturn the distance between this andv.
-
distanceSquared
public float distanceSquared(Vector2fc v)
Description copied from interface:Vector2fcReturn the distance squared between this andv.- Specified by:
distanceSquaredin interfaceVector2fc- Parameters:
v- the other vector- Returns:
- the distance squared
-
distance
public float distance(float x, float y)Description copied from interface:Vector2fcReturn the distance betweenthisvector and(x, y).
-
distanceSquared
public float distanceSquared(float x, float y)Description copied from interface:Vector2fcReturn the distance squared betweenthisvector and(x, y).- Specified by:
distanceSquaredin interfaceVector2fc- Parameters:
x- the x component of the other vectory- the y component of the other vector- Returns:
- the euclidean distance squared
-
distance
public static float distance(float x1, float y1, float x2, float 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 float distanceSquared(float x1, float y1, float x2, float 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 Vector2f normalize()
Normalize this vector.- Returns:
- this
-
normalize
public Vector2f normalize(Vector2f dest)
Description copied from interface:Vector2fcNormalize this vector and store the result indest.
-
normalize
public Vector2f normalize(float length)
Scale this vector to have the given length.- Parameters:
length- the desired length- Returns:
- this
-
normalize
public Vector2f normalize(float length, Vector2f dest)
Description copied from interface:Vector2fcScale this vector to have the given length and store the result indest.
-
add
public Vector2f add(Vector2fc v)
Addvto this vector.- Parameters:
v- the vector to add- Returns:
- this
-
add
public Vector2f add(Vector2fc v, Vector2f dest)
Description copied from interface:Vector2fcAdd the supplied vector to this one and store the result indest.
-
add
public Vector2f add(float x, float y)
Increment the components of this vector by the given values.- Parameters:
x- the x component to addy- the y component to add- Returns:
- this
-
add
public Vector2f add(float x, float y, Vector2f dest)
Description copied from interface:Vector2fcIncrement the components of this vector by the given values and store the result indest.
-
zero
public Vector2f 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 Vector2f negate()
Negate this vector.- Returns:
- this
-
negate
public Vector2f negate(Vector2f dest)
Description copied from interface:Vector2fcNegate this vector and store the result indest.
-
mul
public Vector2f mul(float 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 Vector2f mul(float scalar, Vector2f dest)
Description copied from interface:Vector2fcMultiply the components of this vector by the given scalar and store the result indest.
-
mul
public Vector2f mul(float x, float y)
Multiply the components of this Vector2f 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 Vector2f mul(float x, float y, Vector2f dest)
Description copied from interface:Vector2fcMultiply the components of this Vector2f by the given scalar values and store the result indest.
-
mul
public Vector2f mul(Vector2fc v)
Multiply this Vector2f component-wise by another Vector2f.- Parameters:
v- the vector to multiply by- Returns:
- this
-
mul
public Vector2f mul(Vector2fc v, Vector2f dest)
Description copied from interface:Vector2fcMultiply this Vector2f component-wise by another Vector2f and store the result indest.
-
div
public Vector2f div(Vector2fc v)
Divide this Vector2f component-wise by another Vector2fc.- Parameters:
v- the vector to divide by- Returns:
- this
-
div
public Vector2f div(Vector2fc v, Vector2f dest)
Description copied from interface:Vector2fcDivide this Vector2f component-wise by another Vector2fc and store the result indest.
-
div
public Vector2f div(float scalar)
Divide all components of thisVector2fby the given scalar value.- Parameters:
scalar- the scalar to divide by- Returns:
- this
-
div
public Vector2f div(float scalar, Vector2f dest)
Description copied from interface:Vector2fcDivide all components of thisVector2fby the given scalar value and store the result indest.
-
div
public Vector2f div(float x, float y)
Divide the components of this Vector2f 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 Vector2f div(float x, float y, Vector2f dest)
Description copied from interface:Vector2fcDivide the components of this Vector2f by the given scalar values and store the result indest.
-
mul
public Vector2f mul(Matrix2fc mat)
Multiply the given matrix with this Vector2f and store the result inthis.- Parameters:
mat- the matrix- Returns:
- this
-
mul
public Vector2f mul(Matrix2fc mat, Vector2f dest)
Description copied from interface:Vector2fcMultiply the given matrix with this Vector2f and store the result indest.
-
mul
public Vector2f mul(Matrix2dc mat)
Multiply the given matrix with this Vector2f and store the result inthis.- Parameters:
mat- the matrix- Returns:
- this
-
mul
public Vector2f mul(Matrix2dc mat, Vector2f dest)
Description copied from interface:Vector2fcMultiply the given matrix with this Vector2f and store the result indest.
-
mulTranspose
public Vector2f mulTranspose(Matrix2fc mat)
Multiply the transpose of the given matrix with this Vector2f store the result inthis.- Parameters:
mat- the matrix- Returns:
- this
-
mulTranspose
public Vector2f mulTranspose(Matrix2fc mat, Vector2f dest)
Description copied from interface:Vector2fcMultiply the transpose of the given matrix with this Vector3f and store the result indest.- Specified by:
mulTransposein interfaceVector2fc- Parameters:
mat- the matrixdest- will hold the result- Returns:
- dest
-
mulPosition
public Vector2f mulPosition(Matrix3x2fc 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 Vector2f mulPosition(Matrix3x2fc mat, Vector2f dest)
Description copied from interface:Vector2fcMultiply the given 3x2 matrixmatwiththisand store the result indest.This method assumes the
zcomponent ofthisto be1.0.- Specified by:
mulPositionin interfaceVector2fc- Parameters:
mat- the matrix to multiply this vector bydest- will hold the result- Returns:
- dest
-
mulDirection
public Vector2f mulDirection(Matrix3x2fc 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 Vector2f mulDirection(Matrix3x2fc mat, Vector2f dest)
Description copied from interface:Vector2fcMultiply the given 3x2 matrixmatwiththisand store the result indest.This method assumes the
zcomponent ofthisto be0.0.- Specified by:
mulDirectionin interfaceVector2fc- Parameters:
mat- the matrix to multiply this vector bydest- will hold the result- Returns:
- dest
-
lerp
public Vector2f lerp(Vector2fc other, float 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 Vector2f lerp(Vector2fc other, float t, Vector2f dest)
Description copied from interface:Vector2fcLinearly 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(Vector2fc v, float delta)
Description copied from interface:Vector2fcCompare 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(float x, float y)Description copied from interface:Vector2fcCompare 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 Vector2f fma(Vector2fc a, Vector2fc b)
Add the component-wise multiplication ofa * bto this vector.- Parameters:
a- the first multiplicandb- the second multiplicand- Returns:
- this
-
fma
public Vector2f fma(float a, Vector2fc b)
Add the component-wise multiplication ofa * bto this vector.- Parameters:
a- the first multiplicandb- the second multiplicand- Returns:
- this
-
fma
public Vector2f fma(Vector2fc a, Vector2fc b, Vector2f dest)
Description copied from interface:Vector2fcAdd the component-wise multiplication ofa * bto this vector and store the result indest.
-
fma
public Vector2f fma(float a, Vector2fc b, Vector2f dest)
Description copied from interface:Vector2fcAdd the component-wise multiplication ofa * bto this vector and store the result indest.
-
min
public Vector2f min(Vector2fc 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 Vector2f min(Vector2fc v, Vector2f dest)
Description copied from interface:Vector2fcSet the components ofdestto be the component-wise minimum of this and the other vector.
-
max
public Vector2f max(Vector2fc 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 Vector2f max(Vector2fc v, Vector2f dest)
Description copied from interface:Vector2fcSet the components ofdestto be the component-wise maximum of this and the other vector.
-
maxComponent
public int maxComponent()
Description copied from interface:Vector2fcDetermine the component with the biggest absolute value.- Specified by:
maxComponentin interfaceVector2fc- Returns:
- the component index, within
[0..1]
-
minComponent
public int minComponent()
Description copied from interface:Vector2fcDetermine the component with the smallest (towards zero) absolute value.- Specified by:
minComponentin interfaceVector2fc- Returns:
- the component index, within
[0..1]
-
floor
public Vector2f floor()
Set each component of this vector to the largest (closest to positive infinity)floatvalue that is less than or equal to that component and is equal to a mathematical integer.- Returns:
- this
-
floor
public Vector2f floor(Vector2f dest)
Description copied from interface:Vector2fcCompute for each component of this vector the largest (closest to positive infinity)floatvalue that is less than or equal to that component and is equal to a mathematical integer and store the result indest.
-
ceil
public Vector2f ceil()
Ceil each component of this vector- Returns:
- this
-
ceil
public Vector2f ceil(Vector2f dest)
Description copied from interface:Vector2fcCompute for each component of this vector the smallest (closest to negative infinity)floatvalue that is greater than or equal to that component and is equal to a mathematical integer and store the result indest.
-
round
public Vector2f round()
Set each component of this vector to the closest float that is equal to a mathematical integer, with ties rounding to positive infinity.- Returns:
- this
-
round
public Vector2f round(Vector2f dest)
Description copied from interface:Vector2fcCompute for each component of this vector the closest float 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:Vector2fcDetermine whether all components are finite floating-point values, that is, they are notNaNand notinfinity.
-
absolute
public Vector2f absolute()
Setthisvector's components to their respective absolute values.- Returns:
- this
-
absolute
public Vector2f absolute(Vector2f dest)
Description copied from interface:Vector2fcCompute 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
-
-