public class Vector2 extends Object
| Modifier and Type | Field and Description |
|---|---|
float |
x
Public members
|
float |
y
Public members
|
| Constructor and Description |
|---|
Vector2()
Default constructor, sets x and y to 0
|
Vector2(float x,
float y)
Constructor with arguments
|
Vector2(Vector2 vector)
Constructor from another Vector2
|
| Modifier and Type | Method and Description |
|---|---|
float |
distanceTo(Vector2 vectorTo)
Gets the distance to another Vector (as a point)
|
Vector2 |
divide(float scalar)
Returns the vector divided by the scalar
|
static float |
dot(Vector2 v1,
Vector2 v2)
The dot product of two vectors
|
boolean |
equals(Object obj) |
static Vector2 |
getOne() |
static Vector2 |
getUnitX() |
static Vector2 |
getUnitY() |
static Vector2 |
getZero() |
int |
hashCode() |
float |
magnitude()
Gets the magnitude of a vector
|
float |
magnitudeSqr()
Gets the squared magnitude of the vector
|
Vector2 |
minus(Vector2 v1)
Subtracts one vector from another
|
Vector2 |
multiply(float scalar) |
Vector2 |
negate()
Gets the negated vector
|
Vector2 |
plus(Vector2 v1)
Adds two vectors
|
Vector2 |
scale(float scalar)
Returns the scaled vector
|
String |
toString() |
Vector2 |
unitVector()
Gets the unit (normalised) vector from this vector
|
public Vector2()
public Vector2(float x,
float y)
x - the x-coordinatey - the y-coordinatepublic Vector2(Vector2 vector)
vector - Another 2D Vectorpublic static Vector2 getZero()
public static Vector2 getOne()
public static Vector2 getUnitX()
public static Vector2 getUnitY()
public static float dot(Vector2 v1, Vector2 v2)
v1 - The first vectorv2 - The second vectorpublic float magnitude()
public float magnitudeSqr()
public Vector2 negate()
public Vector2 scale(float scalar)
scalar - the scalar to scale bypublic Vector2 multiply(float scalar)
Vector2.scale(float)public Vector2 divide(float scalar)
scalar - the scalar to divide bypublic Vector2 plus(Vector2 v1)
v1 - the other vectorpublic Vector2 minus(Vector2 v1)
v1 - vector to subtract from thispublic float distanceTo(Vector2 vectorTo)
vectorTo - the vector to measure topublic Vector2 unitVector()
Copyright (c) 2008-2025 Aspose Pty Ltd. All Rights Reserved.