pythagoras.d

## Class Vectors

• ```public class Vectors
extends Object```
Vector-related utility methods.
• ### Field Summary

Fields
Modifier and Type Field and Description
`static IVector` `MAX_VALUE`
A vector containing the maximum doubleing point value for all components.
`static IVector` `MIN_VALUE`
A vector containing the minimum doubleing point value for all components (note: the components are -`Float.MAX_VALUE`, not `Float.MIN_VALUE`).
`static IVector` `UNIT_X`
A unit vector in the X+ direction.
`static IVector` `UNIT_Y`
A unit vector in the Y+ direction.
`static IVector` `ZERO`
The zero vector.
• ### Constructor Summary

Constructors
Constructor and Description
`Vectors()`
• ### Method Summary

All Methods
Modifier and Type Method and Description
`static boolean` ```epsilonEquals(IVector v1, IVector v2)```
Returns true if the supplied vectors' x and y components are equal to one another within `MathUtil.EPSILON`.
`static boolean` ```epsilonEquals(IVector v1, IVector v2, double epsilon)```
Returns true if the supplied vectors' x and y components are equal to one another within `epsilon`.
`static Vector` ```from(XY from, XY to)```
Creates a vector from `from` to `to`.
`static Vector` ```fromPolar(double magnitude, double angle)```
Creates a new vector from polar coordinates.
`static Vector` ```inverseTransform(double x, double y, double sx, double sy, double rotation, Vector result)```
Inverse transforms a vector as specified, storing the result in the vector provided.
`static boolean` ```isEpsilonZero(double x, double y)```
Returns true if the supplied vector's x and y components are `MathUtil.EPSILON` close to zero magnitude.
`static boolean` ```isEpsilonZero(double x, double y, double epsilon)```
Returns true if the supplied vector's x and y components are `epsilon` close to zero magnitude.
`static boolean` ```isZero(double x, double y)```
Returns true if the supplied vector has zero magnitude.
`static double` ```length(double x, double y)```
Returns the magnitude of the specified vector.
`static double` ```lengthSq(double x, double y)```
Returns the square of the magnitude of the specified vector.
`static Vector` ```transform(double x, double y, double sx, double sy, double sina, double cosa, double tx, double ty, Vector result)```
Transforms a vector as specified (as a point, accounting for translation), storing the result in the vector provided.
`static Vector` ```transform(double x, double y, double sx, double sy, double rotation, double tx, double ty, Vector result)```
Transforms a vector as specified (as a point, accounting for translation), storing the result in the vector provided.
`static Vector` ```transform(double x, double y, double sx, double sy, double sina, double cosa, Vector result)```
Transforms a vector as specified, storing the result in the vector provided.
`static Vector` ```transform(double x, double y, double sx, double sy, double rotation, Vector result)```
Transforms a vector as specified, storing the result in the vector provided.
`static String` ```vectorToString(double x, double y)```
Returns a string describing the supplied vector, of the form `+x+y`, `+x-y`, `-x-y`, etc.
• ### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Field Detail

• #### UNIT_X

`public static final IVector UNIT_X`
A unit vector in the X+ direction.
• #### UNIT_Y

`public static final IVector UNIT_Y`
A unit vector in the Y+ direction.
• #### ZERO

`public static final IVector ZERO`
The zero vector.
• #### MAX_VALUE

`public static final IVector MAX_VALUE`
A vector containing the maximum doubleing point value for all components.
• ### Constructor Detail

• #### Vectors

`public Vectors()`
• ### Method Detail

• #### fromPolar

```public static Vector fromPolar(double magnitude,
double angle)```
Creates a new vector from polar coordinates.
• #### from

```public static Vector from(XY from,
XY to)```
Creates a vector from `from` to `to`.
• #### length

```public static double length(double x,
double y)```
Returns the magnitude of the specified vector.
• #### lengthSq

```public static double lengthSq(double x,
double y)```
Returns the square of the magnitude of the specified vector.
• #### isZero

```public static boolean isZero(double x,
double y)```
Returns true if the supplied vector has zero magnitude.
• #### isEpsilonZero

```public static boolean isEpsilonZero(double x,
double y)```
Returns true if the supplied vector's x and y components are `MathUtil.EPSILON` close to zero magnitude.
• #### isEpsilonZero

```public static boolean isEpsilonZero(double x,
double y,
double epsilon)```
Returns true if the supplied vector's x and y components are `epsilon` close to zero magnitude.
• #### epsilonEquals

```public static boolean epsilonEquals(IVector v1,
IVector v2)```
Returns true if the supplied vectors' x and y components are equal to one another within `MathUtil.EPSILON`.
• #### epsilonEquals

```public static boolean epsilonEquals(IVector v1,
IVector v2,
double epsilon)```
Returns true if the supplied vectors' x and y components are equal to one another within `epsilon`.
• #### transform

```public static Vector transform(double x,
double y,
double sx,
double sy,
double rotation,
double tx,
double ty,
Vector result)```
Transforms a vector as specified (as a point, accounting for translation), storing the result in the vector provided.
Returns:
a reference to the result vector, for chaining.
• #### transform

```public static Vector transform(double x,
double y,
double sx,
double sy,
double rotation,
Vector result)```
Transforms a vector as specified, storing the result in the vector provided.
Returns:
a reference to the result vector, for chaining.
• #### transform

```public static Vector transform(double x,
double y,
double sx,
double sy,
double sina,
double cosa,
Vector result)```
Transforms a vector as specified, storing the result in the vector provided.
Returns:
a reference to the result vector, for chaining.
• #### transform

```public static Vector transform(double x,
double y,
double sx,
double sy,
double sina,
double cosa,
double tx,
double ty,
Vector result)```
Transforms a vector as specified (as a point, accounting for translation), storing the result in the vector provided.
Returns:
a reference to the result vector, for chaining.
• #### inverseTransform

```public static Vector inverseTransform(double x,
double y,
double sx,
double sy,
double rotation,
Vector result)```
Inverse transforms a vector as specified, storing the result in the vector provided.
Returns:
a reference to the result vector, for chaining.
• #### vectorToString

```public static String vectorToString(double x,
double y)```
Returns a string describing the supplied vector, of the form `+x+y`, `+x-y`, `-x-y`, etc.