public class Vector2f extends Object implements Externalizable, Vector2fc
| Modifier and Type | Field and Description |
|---|---|
float |
x
The x component of the vector.
|
float |
y
The y component of the vector.
|
| Constructor and Description |
|---|
Vector2f()
Create a new
Vector2f and initialize its components to zero. |
Vector2f(ByteBuffer buffer)
Create a new
Vector2f and read this vector from the supplied ByteBuffer
at the current buffer position. |
Vector2f(float d)
Create a new
Vector2f and initialize both of its components with the given value. |
Vector2f(FloatBuffer buffer)
Create a new
Vector2f and read this vector from the supplied FloatBuffer
at the current buffer position. |
Vector2f(float x,
float y)
Create a new
Vector2f and initialize its components to the given values. |
Vector2f(int index,
ByteBuffer buffer)
Create a new
Vector2f and read this vector from the supplied ByteBuffer
starting at the specified absolute buffer position/index. |
Vector2f(int index,
FloatBuffer buffer)
Create a new
Vector2f and read this vector from the supplied FloatBuffer
starting at the specified absolute buffer position/index. |
Vector2f(Vector2fc v)
Create a new
Vector2f and initialize its components to the one of the given vector. |
Vector2f(Vector2ic v)
Create a new
Vector2f and initialize its components to the one of the given vector. |
| Modifier and Type | Method and Description |
|---|---|
Vector2f |
add(float x,
float y)
Increment the components of this vector by the given values.
|
Vector2f |
add(float x,
float y,
Vector2f dest)
Increment the components of this vector by the given values and store the result in
dest. |
Vector2f |
add(Vector2fc v)
Add
v to this vector. |
Vector2f |
add(Vector2fc v,
Vector2f dest)
Add the supplied vector to this one and store the result in
dest. |
float |
angle(Vector2fc v)
Return the angle between this vector and the supplied vector.
|
Vector2f |
ceil()
Ceil each component of this vector
|
Vector2f |
ceil(Vector2f dest)
Compute for each component of this vector the smallest (closest to negative
infinity)
float value that is greater than or equal to that
component and is equal to a mathematical integer and store the result in
dest. |
float |
distance(float x,
float y)
Return the distance between
this vector and (x, y). |
static float |
distance(float x1,
float y1,
float x2,
float y2)
Return the distance between
(x1, y1) and (x2, y2). |
float |
distance(Vector2fc v)
Return the distance between this and
v. |
float |
distanceSquared(float x,
float y)
Return the distance squared between
this vector and (x, y). |
static float |
distanceSquared(float x1,
float y1,
float x2,
float y2)
Return the squared distance between
(x1, y1) and (x2, y2). |
float |
distanceSquared(Vector2fc v)
Return the distance squared between this and
v. |
float |
dot(Vector2fc v)
Return the dot product of this vector and
v. |
boolean |
equals(float x,
float y)
Compare the vector components of
this vector with the given (x, y)
and return whether all of them are equal. |
boolean |
equals(Object obj) |
boolean |
equals(Vector2fc v,
float delta)
Compare the vector components of
this vector with the given vector using the given delta
and return whether all of them are equal within a maximum difference of delta. |
Vector2f |
floor()
Set each component of this vector to the largest (closest to positive
infinity)
float value that is less than or equal to that
component and is equal to a mathematical integer. |
Vector2f |
floor(Vector2f dest)
Compute for each component of this vector the largest (closest to positive
infinity)
float value that is less than or equal to that
component and is equal to a mathematical integer and store the result in
dest. |
Vector2f |
fma(float a,
Vector2fc b)
Add the component-wise multiplication of
a * b to this vector. |
Vector2f |
fma(float a,
Vector2fc b,
Vector2f dest)
Add the component-wise multiplication of
a * b to this vector
and store the result in dest. |
Vector2f |
fma(Vector2fc a,
Vector2fc b)
Add the component-wise multiplication of
a * b to this vector. |
Vector2f |
fma(Vector2fc a,
Vector2fc b,
Vector2f dest)
Add the component-wise multiplication of
a * b to this vector
and store the result in dest. |
ByteBuffer |
get(ByteBuffer buffer)
Store this vector into the supplied
ByteBuffer at the current
buffer position. |
FloatBuffer |
get(FloatBuffer buffer)
Store this vector into the supplied
FloatBuffer at the current
buffer position. |
float |
get(int component)
Get the value of the specified component of this vector.
|
ByteBuffer |
get(int index,
ByteBuffer buffer)
Store this vector into the supplied
ByteBuffer starting at the specified
absolute buffer position/index. |
FloatBuffer |
get(int index,
FloatBuffer buffer)
Store this vector into the supplied
FloatBuffer starting at the specified
absolute buffer position/index. |
int |
hashCode() |
boolean |
isFinite()
|
float |
length()
Return the length of this vector.
|
static float |
length(float x,
float y)
Get the length of a 2-dimensional single-precision vector.
|
float |
lengthSquared()
Return the length squared of this vector.
|
static float |
lengthSquared(float x,
float y)
Get the length squared of a 2-dimensional single-precision vector.
|
Vector2f |
lerp(Vector2fc other,
float t)
Linearly interpolate
this and other using the given interpolation factor t
and store the result in this. |
Vector2f |
lerp(Vector2fc other,
float t,
Vector2f dest)
Linearly interpolate
this and other using the given interpolation factor t
and store the result in dest. |
Vector2f |
max(Vector2fc v)
Set the components of this vector to be the component-wise maximum of this and the other vector.
|
Vector2f |
max(Vector2fc v,
Vector2f dest)
Set the components of
dest to be the component-wise maximum of this and the other vector. |
int |
maxComponent()
Determine the component with the biggest absolute value.
|
Vector2f |
min(Vector2fc v)
Set the components of this vector to be the component-wise minimum of this and the other vector.
|
Vector2f |
min(Vector2fc v,
Vector2f dest)
Set the components of
dest to be the component-wise minimum of this and the other vector. |
int |
minComponent()
Determine the component with the smallest (towards zero) absolute value.
|
Vector2f |
mul(float scalar)
Multiply the components of this vector by the given scalar.
|
Vector2f |
mul(float x,
float y)
Multiply the components of this Vector2f by the given scalar values and store the result in
this. |
Vector2f |
mul(float x,
float y,
Vector2f dest)
Multiply the components of this Vector2f by the given scalar values and store the result in
dest. |
Vector2f |
mul(float scalar,
Vector2f dest)
Multiply the components of this vector by the given scalar and store the result in
dest. |
Vector2f |
mul(Matrix2dc mat)
Multiply the given matrix with this Vector2f and store the result in
this. |
Vector2f |
mul(Matrix2dc mat,
Vector2f dest)
Multiply the given matrix with this Vector2f and store the result in
dest. |
Vector2f |
mul(Matrix2fc mat)
Multiply the given matrix with this Vector2f and store the result in
this. |
Vector2f |
mul(Matrix2fc mat,
Vector2f dest)
Multiply the given matrix with this Vector2f and store the result in
dest. |
Vector2f |
mul(Vector2fc v)
Multiply this Vector2f component-wise by another Vector2f.
|
Vector2f |
mul(Vector2fc v,
Vector2f dest)
Multiply this Vector2f component-wise by another Vector2f and store the result in
dest. |
Vector2f |
mulDirection(Matrix3x2fc mat)
Multiply the given 3x2 matrix
mat with this. |
Vector2f |
mulDirection(Matrix3x2fc mat,
Vector2f dest)
Multiply the given 3x2 matrix
mat with this and store the
result in dest. |
Vector2f |
mulPosition(Matrix3x2fc mat)
Multiply the given 3x2 matrix
mat with this. |
Vector2f |
mulPosition(Matrix3x2fc mat,
Vector2f dest)
Multiply the given 3x2 matrix
mat with this and store the
result in dest. |
Vector2f |
mulTranspose(Matrix2fc mat)
Multiply the transpose of the given matrix with this Vector2f store the result in
this. |
Vector2f |
mulTranspose(Matrix2fc mat,
Vector2f dest)
Multiply the transpose of the given matrix with this Vector3f and store the result in
dest. |
Vector2f |
negate()
Negate this vector.
|
Vector2f |
negate(Vector2f dest)
Negate this vector and store the result in
dest. |
Vector2f |
normalize()
Normalize this vector.
|
Vector2f |
normalize(float length)
Scale this vector to have the given length.
|
Vector2f |
normalize(float length,
Vector2f dest)
Scale this vector to have the given length and store the result in
dest. |
Vector2f |
normalize(Vector2f dest)
Normalize this vector and store the result in
dest. |
Vector2f |
perpendicular()
Set this vector to be one of its perpendicular vectors.
|
void |
readExternal(ObjectInput in) |
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.
|
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 in
dest. |
Vector2f |
set(ByteBuffer buffer)
Read this vector from the supplied
ByteBuffer at the current
buffer position. |
Vector2f |
set(float d)
Set the x and y components to the supplied value.
|
Vector2f |
set(FloatBuffer buffer)
Read this vector from the supplied
FloatBuffer at the current
buffer position. |
Vector2f |
set(float x,
float y)
Set the x and y components to the supplied values.
|
Vector2f |
set(int index,
ByteBuffer buffer)
Read this vector from the supplied
ByteBuffer starting at the specified
absolute buffer position/index. |
Vector2f |
set(int index,
FloatBuffer buffer)
Read this vector from the supplied
FloatBuffer starting at the specified
absolute buffer position/index. |
Vector2f |
set(Vector2dc v)
Set this
Vector2f to the values of v. |
Vector2f |
set(Vector2fc v)
Set this
Vector2f to the values of v. |
Vector2f |
set(Vector2ic v)
Set this
Vector2f to the values of v. |
Vector2f |
setComponent(int component,
float value)
Set the value of the specified component of this vector.
|
Vector2f |
sub(float x,
float y)
Subtract
(x, y) from this vector. |
Vector2f |
sub(float x,
float y,
Vector2f dest)
Subtract
(x, y) from this vector and store the result in dest. |
Vector2f |
sub(Vector2fc v)
Subtract
v from this vector. |
Vector2f |
sub(Vector2fc v,
Vector2f dest)
Subtract
v from this vector and store the result in dest. |
String |
toString()
Return a string representation of this vector.
|
String |
toString(NumberFormat formatter)
Return a string representation of this vector by formatting the vector components with the given
NumberFormat. |
void |
writeExternal(ObjectOutput out) |
float |
x() |
float |
y() |
Vector2f |
zero()
Set all components to zero.
|
public float x
public float y
public Vector2f()
Vector2f and initialize its components to zero.public Vector2f(float d)
Vector2f and initialize both of its components with the given value.d - the value of both componentspublic Vector2f(float x,
float y)
Vector2f and initialize its components to the given values.x - the x componenty - the y componentpublic Vector2f(Vector2fc v)
Vector2f and initialize its components to the one of the given vector.v - the Vector2fc to copy the values frompublic Vector2f(Vector2ic v)
Vector2f and initialize its components to the one of the given vector.v - the Vector2ic to copy the values frompublic Vector2f(ByteBuffer buffer)
Vector2f and read this vector from the supplied ByteBuffer
at the current buffer position.
This method will not increment the position of the given ByteBuffer.
In order to specify the offset into the ByteBuffer at which
the vector is read, use Vector2f(int, ByteBuffer), taking
the absolute position as parameter.
buffer - values will be read in x, y orderVector2f(int, ByteBuffer)public Vector2f(int index,
ByteBuffer buffer)
Vector2f and read this vector from the supplied ByteBuffer
starting at the specified absolute buffer position/index.
This method will not increment the position of the given ByteBuffer.
index - the absolute position into the ByteBufferbuffer - values will be read in x, y orderpublic Vector2f(FloatBuffer buffer)
Vector2f and read this vector from the supplied FloatBuffer
at the current buffer position.
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.
buffer - values will be read in x, y orderVector2f(int, FloatBuffer)public Vector2f(int index,
FloatBuffer buffer)
Vector2f and read this vector from the supplied FloatBuffer
starting at the specified absolute buffer position/index.
This method will not increment the position of the given FloatBuffer.
index - the absolute position into the FloatBufferbuffer - values will be read in x, y orderpublic Vector2f set(float d)
d - the value of both componentspublic Vector2f set(float x, float y)
x - the x componenty - the y componentpublic Vector2f set(Vector2fc v)
Vector2f to the values of v.v - the vector to copy frompublic Vector2f set(Vector2ic v)
Vector2f to the values of v.v - the vector to copy frompublic Vector2f set(Vector2dc v)
Vector2f to the values of v.
Note that due to the given vector v storing the components in double-precision,
there is the possibility to lose precision.
v - the vector to copy frompublic Vector2f set(ByteBuffer buffer)
ByteBuffer at the current
buffer position.
This method will not increment the position of the given ByteBuffer.
In order to specify the offset into the ByteBuffer at which
the vector is read, use set(int, ByteBuffer), taking
the absolute position as parameter.
buffer - values will be read in x, y orderset(int, ByteBuffer)public Vector2f set(int index, ByteBuffer buffer)
ByteBuffer starting at the specified
absolute buffer position/index.
This method will not increment the position of the given ByteBuffer.
index - the absolute position into the ByteBufferbuffer - values will be read in x, y orderpublic Vector2f set(FloatBuffer buffer)
FloatBuffer at the current
buffer position.
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.
buffer - values will be read in x, y orderset(int, FloatBuffer)public Vector2f set(int index, FloatBuffer buffer)
FloatBuffer starting at the specified
absolute buffer position/index.
This method will not increment the position of the given FloatBuffer.
index - the absolute position into the FloatBufferbuffer - values will be read in x, y orderpublic float get(int component)
throws IllegalArgumentException
Vector2fcget in interface Vector2fccomponent - the component, within [0..1]IllegalArgumentException - if component is not within [0..1]public Vector2f setComponent(int component, float value) throws IllegalArgumentException
component - the component whose value to set, within [0..1]value - the value to setIllegalArgumentException - if component is not within [0..1]public ByteBuffer get(ByteBuffer buffer)
Vector2fcByteBuffer at the current
buffer position.
This method will not increment the position of the given ByteBuffer.
In order to specify the offset into the ByteBuffer at which
the vector is stored, use Vector2fc.get(int, ByteBuffer), taking
the absolute position as parameter.
get in interface Vector2fcbuffer - will receive the values of this vector in x, y orderVector2fc.get(int, ByteBuffer)public ByteBuffer get(int index, ByteBuffer buffer)
Vector2fcByteBuffer starting at the specified
absolute buffer position/index.
This method will not increment the position of the given ByteBuffer.
public FloatBuffer get(FloatBuffer buffer)
Vector2fcFloatBuffer at the current
buffer position.
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.
get in interface Vector2fcbuffer - will receive the values of this vector in x, y orderVector2fc.get(int, FloatBuffer)public FloatBuffer get(int index, FloatBuffer buffer)
Vector2fcFloatBuffer starting at the specified
absolute buffer position/index.
This method will not increment the position of the given FloatBuffer.
public Vector2f perpendicular()
public Vector2f sub(Vector2fc v)
v from this vector.v - the vector to subtractpublic Vector2f sub(Vector2fc v, Vector2f dest)
Vector2fcv from this vector and store the result in dest.public Vector2f sub(float x, float y)
(x, y) from this vector.x - the x component to subtracty - the y component to subtractpublic Vector2f sub(float x, float y, Vector2f dest)
Vector2fc(x, y) from this vector and store the result in dest.public float dot(Vector2fc v)
Vector2fcv.public float angle(Vector2fc v)
Vector2fcpublic float lengthSquared()
Vector2fclengthSquared in interface Vector2fcpublic static float lengthSquared(float x,
float y)
x - The vector's x componenty - The vector's y componentpublic float length()
Vector2fcpublic static float length(float x,
float y)
x - The vector's x componenty - The vector's y componentpublic float distance(Vector2fc v)
Vector2fcv.public float distanceSquared(Vector2fc v)
Vector2fcv.distanceSquared in interface Vector2fcv - the other vectorpublic float distance(float x,
float y)
Vector2fcthis vector and (x, y).public float distanceSquared(float x,
float y)
Vector2fcthis vector and (x, y).distanceSquared in interface Vector2fcx - the x component of the other vectory - the y component of the other vectorpublic static float distance(float x1,
float y1,
float x2,
float y2)
(x1, y1) and (x2, y2).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 vectorpublic static float distanceSquared(float x1,
float y1,
float x2,
float y2)
(x1, y1) and (x2, y2).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 vectorpublic Vector2f normalize()
public Vector2f normalize(Vector2f dest)
Vector2fcdest.public Vector2f normalize(float length)
length - the desired lengthpublic Vector2f normalize(float length, Vector2f dest)
Vector2fcdest.public Vector2f add(Vector2fc v)
v to this vector.v - the vector to addpublic Vector2f add(Vector2fc v, Vector2f dest)
Vector2fcdest.public Vector2f add(float x, float y)
x - the x component to addy - the y component to addpublic Vector2f add(float x, float y, Vector2f dest)
Vector2fcdest.public Vector2f zero()
public void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface ExternalizableIOExceptionpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface ExternalizableIOExceptionClassNotFoundExceptionpublic Vector2f negate()
public Vector2f negate(Vector2f dest)
Vector2fcdest.public Vector2f mul(float scalar)
scalar - the value to multiply this vector's components bypublic Vector2f mul(float scalar, Vector2f dest)
Vector2fcdest.public Vector2f mul(float x, float y)
this.x - the x component to multiply this vector byy - the y component to multiply this vector bypublic Vector2f mul(float x, float y, Vector2f dest)
Vector2fcdest.public Vector2f mul(Vector2fc v)
v - the vector to multiply bypublic Vector2f mul(Vector2fc v, Vector2f dest)
Vector2fcdest.public Vector2f mul(Matrix2fc mat)
this.mat - the matrixpublic Vector2f mul(Matrix2fc mat, Vector2f dest)
Vector2fcdest.public Vector2f mul(Matrix2dc mat)
this.mat - the matrixpublic Vector2f mul(Matrix2dc mat, Vector2f dest)
Vector2fcdest.public Vector2f mulTranspose(Matrix2fc mat)
this.mat - the matrixpublic Vector2f mulTranspose(Matrix2fc mat, Vector2f dest)
Vector2fcdest.mulTranspose in interface Vector2fcmat - the matrixdest - will hold the resultpublic Vector2f mulPosition(Matrix3x2fc mat)
mat with this.
This method assumes the z component of this to be 1.0.
mat - the matrix to multiply this vector bypublic Vector2f mulPosition(Matrix3x2fc mat, Vector2f dest)
Vector2fcmat with this and store the
result in dest.
This method assumes the z component of this to be 1.0.
mulPosition in interface Vector2fcmat - the matrix to multiply this vector bydest - will hold the resultpublic Vector2f mulDirection(Matrix3x2fc mat)
mat with this.
This method assumes the z component of this to be 0.0.
mat - the matrix to multiply this vector bypublic Vector2f mulDirection(Matrix3x2fc mat, Vector2f dest)
Vector2fcmat with this and store the
result in dest.
This method assumes the z component of this to be 0.0.
mulDirection in interface Vector2fcmat - the matrix to multiply this vector bydest - will hold the resultpublic Vector2f lerp(Vector2fc other, float t)
this and other using the given interpolation factor t
and store the result in this.
If t is 0.0 then the result is this. If the interpolation factor is 1.0
then the result is other.
other - the other vectort - the interpolation factor between 0.0 and 1.0public Vector2f lerp(Vector2fc other, float t, Vector2f dest)
Vector2fcthis and other using the given interpolation factor t
and store the result in dest.
If t is 0.0 then the result is this. If the interpolation factor is 1.0
then the result is other.
public boolean equals(Vector2fc v, float delta)
Vector2fcthis vector with the given vector using the given delta
and return whether all of them are equal within a maximum difference of delta.
Please note that this method is not used by any data structure such as ArrayList HashSet or HashMap
and their operations, such as ArrayList.contains(Object) or HashSet.remove(Object), since those
data structures only use the Object.equals(Object) and Object.hashCode() methods.
public boolean equals(float x,
float y)
Vector2fcthis vector with the given (x, y)
and return whether all of them are equal.public String toString()
This method creates a new DecimalFormat on every invocation with the format string "0.000E0;-".
public String toString(NumberFormat formatter)
NumberFormat.formatter - the NumberFormat used to format the vector components withpublic Vector2f fma(Vector2fc a, Vector2fc b)
a * b to this vector.a - the first multiplicandb - the second multiplicandpublic Vector2f fma(float a, Vector2fc b)
a * b to this vector.a - the first multiplicandb - the second multiplicandpublic Vector2f fma(Vector2fc a, Vector2fc b, Vector2f dest)
Vector2fca * b to this vector
and store the result in dest.public Vector2f fma(float a, Vector2fc b, Vector2f dest)
Vector2fca * b to this vector
and store the result in dest.public Vector2f min(Vector2fc v)
v - the other vectorpublic Vector2f min(Vector2fc v, Vector2f dest)
Vector2fcdest to be the component-wise minimum of this and the other vector.public Vector2f max(Vector2fc v)
v - the other vectorpublic Vector2f max(Vector2fc v, Vector2f dest)
Vector2fcdest to be the component-wise maximum of this and the other vector.public int maxComponent()
Vector2fcmaxComponent in interface Vector2fc[0..1]public int minComponent()
Vector2fcminComponent in interface Vector2fc[0..1]public Vector2f floor()
float value that is less than or equal to that
component and is equal to a mathematical integer.public Vector2f floor(Vector2f dest)
Vector2fcfloat value that is less than or equal to that
component and is equal to a mathematical integer and store the result in
dest.public Vector2f ceil()
public Vector2f ceil(Vector2f dest)
Vector2fcfloat value that is greater than or equal to that
component and is equal to a mathematical integer and store the result in
dest.public Vector2f round()
public Vector2f round(Vector2f dest)
Vector2fcdest.public boolean isFinite()
Vector2fcCopyright © 2015–2019 JOML. All rights reserved.