public class Vector2f
extends java.lang.Object
implements java.io.Serializable
| Modifier and Type | Field and Description | 
|---|---|
| float | xThe x component of this vector | 
| float | yThe y component of this vector | 
| Constructor and Description | 
|---|
| Vector2f()Create an empty vector | 
| Vector2f(double theta)Create a new vector based on an angle | 
| Vector2f(float[] coords)Create a vector based on the contents of a coordinate array | 
| Vector2f(float x,
        float y)Create a new vector | 
| Vector2f(Vector2f other)Create a new vector based on another | 
| Modifier and Type | Method and Description | 
|---|---|
| Vector2f | add(double theta)Adjust this vector by a given angle | 
| Vector2f | add(Vector2f v)Add a vector to this vector | 
| Vector2f | copy()Return a copy of this vector | 
| float | distance(Vector2f other)Get the distance from this point to another | 
| float | distanceSquared(Vector2f other)Get the distance from this point to another, squared. | 
| float | dot(Vector2f other)Dot this vector against another | 
| boolean | equals(java.lang.Object other) | 
| Vector2f | getNormal()The normal of the vector | 
| Vector2f | getPerpendicular()A vector perpendicular to this vector. | 
| double | getTheta()Get the angle this vector is at | 
| float | getX()Get the x component | 
| float | getY()Get the y component | 
| int | hashCode() | 
| float | length()Get the length of this vector | 
| float | lengthSquared()The length of the vector squared | 
| Vector2f | negate()Negate this vector | 
| Vector2f | negateLocal()Negate this vector without creating a new copy | 
| Vector2f | normalise()Normalise the vector | 
| void | projectOntoUnit(Vector2f b,
               Vector2f result)Project this vector onto another | 
| Vector2f | scale(float a)Scale this vector by a value | 
| Vector2f | set(float[] pt)Set the values in this vector | 
| Vector2f | set(float x,
   float y)Set the values in this vector | 
| void | set(Vector2f other)Set the value of this vector | 
| void | setTheta(double theta)Calculate the components of the vectors based on a angle | 
| Vector2f | sub(double theta)Adjust this vector by a given angle | 
| Vector2f | sub(Vector2f v)Subtract a vector from this vector | 
| java.lang.String | toString() | 
public float x
public float y
public Vector2f()
public Vector2f(float[] coords)
coords - The coordinates array, index 0 = x, index 1 = ypublic Vector2f(double theta)
theta - The angle of the vector in degreespublic Vector2f(Vector2f other)
other - The other vector to copy into this onepublic Vector2f(float x,
                float y)
x - The x component to assigny - The y component to assignpublic void setTheta(double theta)
theta - The angle to calculate the components from (in degrees)public Vector2f add(double theta)
theta - The angle to adjust the angle by (in degrees)public Vector2f sub(double theta)
theta - The angle to adjust the angle by (in degrees)public double getTheta()
public float getX()
public float getY()
public void set(Vector2f other)
other - The values to set into the vectorpublic float dot(Vector2f other)
other - The other vector dot agianstpublic Vector2f set(float x, float y)
x - The x component to sety - The y component to setpublic Vector2f getPerpendicular()
public Vector2f set(float[] pt)
pt - The pair of values to set into the vectorpublic Vector2f negate()
public Vector2f negateLocal()
public Vector2f add(Vector2f v)
v - The vector to addpublic Vector2f sub(Vector2f v)
v - The vector subtractpublic Vector2f scale(float a)
a - The value to scale this vector bypublic Vector2f normalise()
public Vector2f getNormal()
public float lengthSquared()
public float length()
public void projectOntoUnit(Vector2f b, Vector2f result)
b - The vector to project ontoresult - The projected vectorpublic Vector2f copy()
public java.lang.String toString()
toString in class java.lang.ObjectObject.toString()public float distance(Vector2f other)
other - The other point we're measuring topublic float distanceSquared(Vector2f other)
other - The other point we're measuring topublic int hashCode()
hashCode in class java.lang.ObjectObject.hashCode()public boolean equals(java.lang.Object other)
equals in class java.lang.ObjectObject.equals(java.lang.Object)