AI for Games 1.1.1
|
Public Member Functions | |
Vector2D () | |
Vector2D (double x, double y) | |
Vector2D (final Vector2D v) | |
void | set (final Vector2D v) |
void | set (double x, double y) |
double | lengthSq () |
double | length () |
double | dot (final Vector2D v) |
double | dotNorm (final Vector2D v) |
double | angleBetween (final Vector2D v) |
int | sign (final Vector2D v) |
Vector2D | get () |
Vector2D | getPerp () |
double | distanceSq (final Vector2D v) |
double | distance (final Vector2D v) |
Vector2D | normalize () |
Vector2D | truncate (double max) |
Vector2D | getReverse () |
Vector2D | getReflect (final Vector2D norm) |
Vector2D | add (final Vector2D v) |
Vector2D | add (double dx, double dy) |
Vector2D | sub (final Vector2D v) |
Vector2D | mult (double d) |
Vector2D | div (double d) |
double[] | toArray () |
String | toShortString () |
String | toString () |
Static Public Member Functions | |
static boolean | areEqual (Vector2D v0, Vector2D v1) |
static Vector2D | add (final Vector2D v0, final Vector2D v1) |
static Vector2D | sub (final Vector2D v0, final Vector2D v1) |
static Vector2D | mult (final Vector2D v, double d) |
static Vector2D | div (final Vector2D v, double d) |
static double | distSq (final Vector2D v0, final Vector2D v1) |
static double | dist (final Vector2D v0, final Vector2D v1) |
static Vector2D | normalize (final Vector2D v) |
static double | angleBetween (Vector2D v0, Vector2D v1) |
static boolean | isSecondInFOVofFirstXXX (final Vector2D posFirst, final Vector2D facingFirst, final double fovFirst, final Vector2D posSecond) |
static Vector2D | random (Vector2D target) |
Public Attributes | |
double | x |
double | y |
Static Public Attributes | |
static final Vector2D | ZERO = new Vector2D(0, 0) |
static final Vector2D | ONE = new Vector2D(1, 1) |
static final Vector2D | PLUS_I = new Vector2D(1, 0) |
static final Vector2D | MINUS_I = new Vector2D(-1, 0) |
static final Vector2D | PLUS_J = new Vector2D(0, 1) |
static final Vector2D | MINUS_J = new Vector2D(0, -1) |
static final Vector2D | NaN = new Vector2D(Double.NaN, Double.NaN) |
static final Vector2D | POSITIVE_INFINITY |
static final Vector2D | NEGATIVE_INFINITY |
static final double | EPSILON = 1e-10 |
static final int | CLOCKWISE = 1 |
static final int | ANTI_CLOCKWISE = -1 |
Static Private Attributes | |
static final long | serialVersionUID = -7691691832344874590L |
This 2D vector class uses the double data type throughout.
game2dai.maths.Vector2D.Vector2D | ( | ) |
Default to the zero vector
game2dai.maths.Vector2D.Vector2D | ( | double | x, |
double | y | ||
) |
Create a vector based on parameter values.
x | |
y |
game2dai.maths.Vector2D.Vector2D | ( | final Vector2D | v | ) |
Copy constructor
v | the vector to copy |
Vector2D game2dai.maths.Vector2D.add | ( | double | dx, |
double | dy | ||
) |
Change the vector by the values specified
dx | |
dy |
Add a vector to this one
v | the vector to add |
Get a new vector that is the sum of 2 vectors.
v0 | first vector |
v1 | second vector |
double game2dai.maths.Vector2D.angleBetween | ( | final Vector2D | v | ) |
Calculate the angle between this and another vector.
v | the other vector |
Calculate the angle between two vectors.
v0 | first vector |
v1 | second vector |
The distance between two vectors
v0 | the first vector |
v1 | the second vector |
double game2dai.maths.Vector2D.distance | ( | final Vector2D | v | ) |
Get the distance between this and an other point.
v | the other point |
double game2dai.maths.Vector2D.distanceSq | ( | final Vector2D | v | ) |
Get the distance squared between this and another point.
v | the other point |
The square of the distance between two vectors
v0 | the first vector |
v1 | the second vector |
Vector2D game2dai.maths.Vector2D.div | ( | double | d | ) |
Divide the vector by a scalar
d |
Get a new vector that is a vector divided by a scalar
v | the original vector |
d | the divisor |
double game2dai.maths.Vector2D.dot | ( | final Vector2D | v | ) |
Calculate the dot product between two un-normalised vectors.
v | the other vector |
double game2dai.maths.Vector2D.dotNorm | ( | final Vector2D | v | ) |
Calculate the dot product between two vectors using normalised values i.e. the cosine of the angle between them
v | the other vector |
Vector2D game2dai.maths.Vector2D.get | ( | ) |
Get a copy (new object) of this vector.
Vector2D game2dai.maths.Vector2D.getPerp | ( | ) |
Get a vector perpendicular to this one.
Return the reflection vector about the norm
norm |
Vector2D game2dai.maths.Vector2D.getReverse | ( | ) |
Get a vector that is the reverse of this vector
|
static |
Determines whether entity 2 is visible from entity 1.
posFirst | position of first entity |
facingFirst | direction first entity is facing |
fovFirst | field of view (radians) |
posSecond | position of second entity |
double game2dai.maths.Vector2D.length | ( | ) |
Get the vector length
double game2dai.maths.Vector2D.lengthSq | ( | ) |
Get the vector length squared
Vector2D game2dai.maths.Vector2D.mult | ( | double | d | ) |
Multiply the vector by a scalar
d |
Get a new vector that is the product of a vector and a scalar
v | the original vector |
d | the multiplier |
Vector2D game2dai.maths.Vector2D.normalize | ( | ) |
Normalise this vector
Get a new vector that is the given vector normalised
v | the original vector |
Create a random normalised vector.
target | the vector to randomise, create a vector if null |
int game2dai.maths.Vector2D.sign | ( | final Vector2D | v | ) |
Determines whether vector v is clockwise of this vector.
v | a vector |
Get a new vector that is the difference between the 2 vectors.
v0 | first vector |
v1 | second vector |
double[] game2dai.maths.Vector2D.toArray | ( | ) |
Get the coordinates as an array.
Vector2D game2dai.maths.Vector2D.truncate | ( | double | max | ) |
Truncate this vector so its length is no greater than the value provided.
max | maximum size for this vector |
Opposite of the first canonical vector (coordinates: -1, 0).
Opposite of the second canonical vector (coordinates: 0, -1).
A vector with all coordinates set to NaN.
|
static |
A vector with all coordinates set to negative infinity.
Null vector (coordinates: 1, 1).
First canonical vector (coordinates: 1, 0).
Second canonical vector (coordinates: 0, 1).
|
static |
A vector with all coordinates set to positive infinity.
Null vector (coordinates: 0, 0).