public class Vector<NUMBER extends AbstractNumber = Double>:
Represents a two-dimensional vector.
Vector is intended for displacement and direction math. Use Point for absolute positions.
Example:
velocity = Vector<Double>(3.0, 4.0) print(velocity.magnitude())
| Modifier and Type | Member | Description |
|---|---|---|
| public property | xx as NUMBER |
Horizontal component. |
| public propert | yy y as NUMBER |
Vertical component. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | VectorVector(x as NUMBER, y as NUMBER): |
Creates a vector from its components. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | cross | Computes the two-dimensional cross product determinant. |
| public | dot | Computes the dot product with another vector. |
| public | magnitudemagnitude() as Double: |
Computes the Euclidean vector length. |
| public | normalize | Returns a unit vector with the same direction. |
| public override | toStringtoString() as String: |
Returns a readable representation of the vector. |
| Modifier and Type | Member | Description |
|---|---|---|
| public static | operator*(v1 as Vector<NUMBER>, scalar as NUMBER) as Vector<NUMBER>: | Multiplies a vector by a scalar. |
| public static | operator+(v1 as Vector<NUMBER>, v2 as Vector<NUMBER>) as Vector<NUMBER>: | Adds two vectors component by component. |
| public static | operator-(v1 as Vector<NUMBER>, v2 as Vector<NUMBER>) as Vector<NUMBER>: | Subtracts two vectors component by component. |
| public static | operator/(v1 as Vector<NUMBER>, scalar as NUMBER) as Vector<Double>: | Divides a vector by a scalar. |