public class Vector2f extends Object implements Externalizable
| Modifier and Type | Field and Description |
|---|---|
float |
x
The x-coordinate of the vector.
|
float |
y
The y-coordinate of the vector.
|
| Constructor and Description |
|---|
Vector2f()
Create a new
Vector2f and initialize its components to zero. |
Vector2f(float x,
float y)
Create a new
Vector2f and initialize its components to the given values. |
Vector2f(Vector2f v)
Create a new
Vector2f and initialize its components to the one of the given vector. |
| Modifier and Type | Method and Description |
|---|---|
Vector2f |
add(Vector2f v)
Add
v to this vector. |
static void |
add(Vector2f a,
Vector2f b,
Vector2f dest)
Add
a to b and store the result in dest. |
float |
angle(Vector2f v)
Return the angle between this vector and the supplied vector.
|
float |
distance(Vector2f v)
Return the distance between this and
v. |
float |
dot(Vector2f v)
Return the dot product of this vector and
v. |
boolean |
equals(Object obj) |
int |
hashCode() |
float |
length()
Return the length of this vector.
|
float |
lengthSquared()
Return the length squared of this vector.
|
Vector2f |
mul(float scalar)
Multiply the components of this vector by the given scalar.
|
Vector2f |
mul(float scalar,
Vector2f dest)
Multiply the components of this vector by the given scalar and store the result in
dest. |
Vector2f |
mul(Matrix3f m)
Multiply this vector by the given matrix.
|
Vector2f |
mul(Matrix3f m,
Vector2f dest)
Multiply this vector by the given matrix 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(Vector2f dest)
Normalize this vector and store the result in
dest. |
Vector2f |
perpendicular()
Set this vector to be one of its perpendicular vectors.
|
static void |
perpendicular(Vector2f v,
Vector2f dest)
Store one perpendicular vector of
v in dest. |
void |
readExternal(ObjectInput in) |
Vector2f |
set(float x,
float y)
Set the x and y attributes to the supplied values.
|
Vector2f |
set(Vector2f v)
Set this
Vector2f to the values of v. |
Vector2f |
sub(float x,
float y)
Subtract (x, y) from this vector.
|
Vector2f |
sub(Vector2f v)
Subtract
v from this vector. |
static void |
sub(Vector2f a,
Vector2f b,
Vector2f dest)
Subtract
b from a 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) |
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 x,
float y)
Vector2f and initialize its components to the given values.x - the x valuey - the y valuepublic Vector2f set(float x, float y)
x - the x value to sety - the y value to setpublic Vector2f set(Vector2f v)
Vector2f to the values of v.v - the vector to copy frompublic static void perpendicular(Vector2f v, Vector2f dest)
v in dest.v - the vector to build one perpendicular vector ofdest - will hold the resultpublic Vector2f perpendicular()
public static void sub(Vector2f a, Vector2f b, Vector2f dest)
b from a and store the result in dest.a - the first operandb - the second operanddest - will hold the result of a - bpublic Vector2f sub(Vector2f v)
v from this vector.v - the vector to subtract from thispublic Vector2f sub(float x, float y)
x - the x-coordinate to subtracty - the y-coordinate to subtractpublic float dot(Vector2f v)
v.v - the other vectorpublic float angle(Vector2f v)
v - the other vectorpublic float length()
public float lengthSquared()
public float distance(Vector2f v)
v.v - the other vectorpublic Vector2f normalize()
public Vector2f normalize(Vector2f dest)
dest.dest - will hold the resultpublic Vector2f add(Vector2f v)
v to this vector.v - the vector to addpublic static void add(Vector2f a, Vector2f b, Vector2f dest)
a to b and store the result in dest.a - the first addendb - the second addenddest - will hold the resultpublic 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)
dest.dest - will hold the resultpublic Vector2f mul(float scalar)
scalar - the value to multiply this vector's components bypublic Vector2f mul(float scalar, Vector2f dest)
dest.scalar - the value to multiply this vector's components bydest - will hold the resultpublic Vector2f mul(Matrix3f m)
m - the matrix to multiply this vector bypublic Vector2f mul(Matrix3f m, Vector2f dest)
dest.m - the matrix to multiply this vector bydest - will hold the resultpublic 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 withCopyright © 2015 JOML. All rights reserved.