Interface Vector2fc
-
- All Known Implementing Classes:
Vector2f
public interface Vector2fcInterface to a read-only view of a 2-dimensional vector of single-precision floats.- Author:
- Kai Burjack
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Vector2fabsolute(Vector2f dest)Compute the absolute of each of this vector's components and store the result intodest.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, 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(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.floatdistance(float x, float y)Return the distance betweenthisvector and(x, y).floatdistance(Vector2fc v)Return the distance between this andv.floatdistanceSquared(float x, float y)Return the distance squared betweenthisvector and(x, y).floatdistanceSquared(Vector2fc v)Return the distance squared between this andv.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, 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(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(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, Vector2f dest)Add the component-wise multiplication ofa * bto this vector and store the result indest.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.booleanisFinite()Determine whether all components are finite floating-point values, that is, they are notNaNand notinfinity.floatlength()Return the length of this vector.floatlengthSquared()Return the length squared of this vector.Vector2flerp(Vector2fc other, float t, Vector2f dest)Linearly interpolatethisandotherusing the given interpolation factortand store the result indest.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, 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 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, Vector2f dest)Multiply the given matrix with this Vector2f and store the result indest.Vector2fmul(Matrix2fc mat, Vector2f dest)Multiply the given matrix with this Vector2f and store the result indest.Vector2fmul(Vector2fc v, Vector2f dest)Multiply this Vector2f component-wise by another Vector2f and store the result indest.Vector2fmulDirection(Matrix3x2fc mat, Vector2f dest)Multiply the given 3x2 matrixmatwiththisand store the result indest.Vector2fmulPosition(Matrix3x2fc mat, Vector2f dest)Multiply the given 3x2 matrixmatwiththisand store the result indest.Vector2fmulTranspose(Matrix2fc mat, Vector2f dest)Multiply the transpose of the given matrix with this Vector3f and store the result indest.Vector2fnegate(Vector2f dest)Negate this vector and store the result indest.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.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.Vector2fsub(float x, float y, Vector2f dest)Subtract(x, y)from this vector and store the result indest.Vector2fsub(Vector2fc v, Vector2f dest)Subtractvfromthisvector and store the result indest.floatx()floaty()
-
-
-
Method Detail
-
x
float x()
- Returns:
- the value of the x component
-
y
float y()
- Returns:
- the value of the y component
-
get
java.nio.ByteBuffer get(java.nio.ByteBuffer buffer)
Store 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
get(int, ByteBuffer), taking the absolute position as parameter.- Parameters:
buffer- will receive the values of this vector inx, yorder- Returns:
- the passed in buffer
- See Also:
get(int, ByteBuffer)
-
get
java.nio.ByteBuffer get(int index, java.nio.ByteBuffer buffer)Store this vector into 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- will receive the values of this vector inx, yorder- Returns:
- the passed in buffer
-
get
java.nio.FloatBuffer get(java.nio.FloatBuffer buffer)
Store 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
get(int, FloatBuffer), taking the absolute position as parameter.- Parameters:
buffer- will receive the values of this vector inx, yorder- Returns:
- the passed in buffer
- See Also:
get(int, FloatBuffer)
-
get
java.nio.FloatBuffer get(int index, java.nio.FloatBuffer buffer)Store this vector into 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- will receive the values of this vector inx, yorder- Returns:
- the passed in buffer
-
getToAddress
Vector2fc getToAddress(long address)
Store 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.
- Parameters:
address- the off-heap address where to store this vector- Returns:
- this
-
sub
Vector2f sub(Vector2fc v, Vector2f dest)
Subtractvfromthisvector and store the result indest.- Parameters:
v- the vector to subtractdest- will hold the result- Returns:
- dest
-
sub
Vector2f sub(float x, float y, Vector2f dest)
Subtract(x, y)from this vector and store the result indest.- Parameters:
x- the x component to subtracty- the y component to subtractdest- will hold the result- Returns:
- dest
-
dot
float dot(Vector2fc v)
Return the dot product of this vector andv.- Parameters:
v- the other vector- Returns:
- the dot product
-
angle
float angle(Vector2fc v)
Return the angle between this vector and the supplied vector.- Parameters:
v- the other vector- Returns:
- the angle, in radians
-
lengthSquared
float lengthSquared()
Return the length squared of this vector.- Returns:
- the length squared
-
length
float length()
Return the length of this vector.- Returns:
- the length
-
distance
float distance(Vector2fc v)
Return the distance between this andv.- Parameters:
v- the other vector- Returns:
- the distance
-
distanceSquared
float distanceSquared(Vector2fc v)
Return the distance squared between this andv.- Parameters:
v- the other vector- Returns:
- the distance squared
-
distance
float distance(float x, float y)Return the distance betweenthisvector and(x, y).- Parameters:
x- the x component of the other vectory- the y component of the other vector- Returns:
- the euclidean distance
-
distanceSquared
float distanceSquared(float x, float y)Return the distance squared betweenthisvector and(x, y).- Parameters:
x- the x component of the other vectory- the y component of the other vector- Returns:
- the euclidean distance squared
-
normalize
Vector2f normalize(Vector2f dest)
Normalize this vector and store the result indest.- Parameters:
dest- will hold the result- Returns:
- dest
-
normalize
Vector2f normalize(float length, Vector2f dest)
Scale this vector to have the given length and store the result indest.- Parameters:
length- the desired lengthdest- will hold the result- Returns:
- dest
-
add
Vector2f add(Vector2fc v, Vector2f dest)
Add the supplied vector to this one and store the result indest.- Parameters:
v- the vector to adddest- will hold the result- Returns:
- dest
-
add
Vector2f add(float x, float y, Vector2f dest)
Increment the components of this vector by the given values and store the result indest.- Parameters:
x- the x component to addy- the y component to adddest- will hold the result- Returns:
- dest
-
negate
Vector2f negate(Vector2f dest)
Negate this vector and store the result indest.- Parameters:
dest- will hold the result- Returns:
- dest
-
mul
Vector2f mul(float scalar, Vector2f dest)
Multiply the components of this vector by the given scalar and store the result indest.- Parameters:
scalar- the value to multiply this vector's components bydest- will hold the result- Returns:
- dest
-
mul
Vector2f mul(float x, float y, Vector2f dest)
Multiply the components of this Vector2f by the given scalar values and store the result indest.- Parameters:
x- the x component to multiply this vector byy- the y component to multiply this vector bydest- will hold the result- Returns:
- dest
-
mul
Vector2f mul(Vector2fc v, Vector2f dest)
Multiply this Vector2f component-wise by another Vector2f and store the result indest.- Parameters:
v- the vector to multiply bydest- will hold the result- Returns:
- dest
-
div
Vector2f div(float scalar, Vector2f dest)
Divide all components of thisVector2fby the given scalar value and store the result indest.- Parameters:
scalar- the scalar to divide bydest- will hold the result- Returns:
- dest
-
div
Vector2f div(Vector2fc v, Vector2f dest)
Divide this Vector2f component-wise by another Vector2fc and store the result indest.- Parameters:
v- the vector to divide bydest- will hold the result- Returns:
- dest
-
div
Vector2f div(float x, float y, Vector2f dest)
Divide the components of this Vector2f by the given scalar values and store the result indest.- Parameters:
x- the x component to divide this vector byy- the y component to divide this vector bydest- will hold the result- Returns:
- dest
-
mul
Vector2f mul(Matrix2fc mat, Vector2f dest)
Multiply the given matrix with this Vector2f and store the result indest.- Parameters:
mat- the matrixdest- will hold the result- Returns:
- dest
-
mul
Vector2f mul(Matrix2dc mat, Vector2f dest)
Multiply the given matrix with this Vector2f and store the result indest.- Parameters:
mat- the matrixdest- will hold the result- Returns:
- dest
-
mulTranspose
Vector2f mulTranspose(Matrix2fc mat, Vector2f dest)
Multiply the transpose of the given matrix with this Vector3f and store the result indest.- Parameters:
mat- the matrixdest- will hold the result- Returns:
- dest
-
mulPosition
Vector2f mulPosition(Matrix3x2fc mat, Vector2f dest)
Multiply the given 3x2 matrixmatwiththisand store the result indest.This method assumes the
zcomponent ofthisto be1.0.- Parameters:
mat- the matrix to multiply this vector bydest- will hold the result- Returns:
- dest
-
mulDirection
Vector2f mulDirection(Matrix3x2fc mat, Vector2f dest)
Multiply the given 3x2 matrixmatwiththisand store the result indest.This method assumes the
zcomponent ofthisto be0.0.- Parameters:
mat- the matrix to multiply this vector bydest- will hold the result- Returns:
- dest
-
lerp
Vector2f lerp(Vector2fc other, float t, Vector2f dest)
Linearly interpolatethisandotherusing the given interpolation factortand store the result indest.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.0dest- will hold the result- Returns:
- dest
-
fma
Vector2f fma(Vector2fc a, Vector2fc b, Vector2f dest)
Add the component-wise multiplication ofa * bto this vector and store the result indest.- Parameters:
a- the first multiplicandb- the second multiplicanddest- will hold the result- Returns:
- dest
-
fma
Vector2f fma(float a, Vector2fc b, Vector2f dest)
Add the component-wise multiplication ofa * bto this vector and store the result indest.- Parameters:
a- the first multiplicandb- the second multiplicanddest- will hold the result- Returns:
- dest
-
min
Vector2f min(Vector2fc v, Vector2f dest)
Set the components ofdestto be the component-wise minimum of this and the other vector.- Parameters:
v- the other vectordest- will hold the result- Returns:
- dest
-
max
Vector2f max(Vector2fc v, Vector2f dest)
Set the components ofdestto be the component-wise maximum of this and the other vector.- Parameters:
v- the other vectordest- will hold the result- Returns:
- dest
-
maxComponent
int maxComponent()
Determine the component with the biggest absolute value.- Returns:
- the component index, within
[0..1]
-
minComponent
int minComponent()
Determine the component with the smallest (towards zero) absolute value.- Returns:
- the component index, within
[0..1]
-
get
float get(int component) throws java.lang.IllegalArgumentException
Get the value of the specified component of this vector.- Parameters:
component- the component, within[0..1]- Returns:
- the value
- Throws:
java.lang.IllegalArgumentException- ifcomponentis not within[0..1]
-
get
Vector2i get(int mode, Vector2i dest)
- Parameters:
mode- theRoundingModeto usedest- will hold the result- Returns:
- dest
-
get
Vector2f get(Vector2f dest)
Set the components of the given vectordestto those ofthisvector.- Parameters:
dest- will hold the result- Returns:
- dest
-
get
Vector2d get(Vector2d dest)
Set the components of the given vectordestto those ofthisvector.- Parameters:
dest- will hold the result- Returns:
- dest
-
floor
Vector2f floor(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.- Parameters:
dest- will hold the result- Returns:
- dest
-
ceil
Vector2f ceil(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.- Parameters:
dest- will hold the result- Returns:
- dest
-
round
Vector2f round(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.- Parameters:
dest- will hold the result- Returns:
- dest
-
isFinite
boolean isFinite()
Determine whether all components are finite floating-point values, that is, they are notNaNand notinfinity.- Returns:
trueif all components are finite floating-point values;falseotherwise
-
absolute
Vector2f absolute(Vector2f dest)
Compute the absolute of each of this vector's components and store the result intodest.- Parameters:
dest- will hold the result- Returns:
- dest
-
equals
boolean equals(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.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.- Parameters:
v- the other vectordelta- the allowed maximum difference- Returns:
truewhether all of the vector components are equal;falseotherwise
-
equals
boolean equals(float x, float y)Compare the vector components ofthisvector with the given(x, y)and return whether all of them are equal.- Parameters:
x- the x component to compare toy- the y component to compare to- Returns:
trueif all the vector components are equal
-
-