public class Vector2
extends java.lang.Object
Constructor and Description |
---|
Vector2() |
Vector2(float x,
float y) |
Vector2(Vector2 other) |
Modifier and Type | Method and Description |
---|---|
Vector2 |
add(Vector2 other)
Adds this vector to another.
|
float |
dot(Vector2 other)
Calculates the dot product between two vectors.
|
float |
length() |
float |
magnitude() |
Vector2 |
multiply(float m)
Multiplies all components by a constant.
|
float |
normalize()
Sets the length of this vector to 1.
|
Vector2 |
sub(Vector2 other)
Let another vector subtract from this one.
|
Vector2 |
vectorTo(Vector2 other)
Creates a vector pointing from this to the passed vector.
|
public Vector2(float x, float y)
public Vector2(Vector2 other)
public Vector2()
public Vector2 vectorTo(Vector2 other)
The
- reference point.public float length()
public float normalize()
public Vector2 multiply(float m)
m
- The constant by which the components will be multiplied.public float magnitude()
public Vector2 add(Vector2 other)
other
- The other vector which will be addedpublic Vector2 sub(Vector2 other)
other
- The other vector which will be subtracted from this.public float dot(Vector2 other)
other
- The other vector.