Constructor Summary
Public Constructor | ||
public |
constructor(x: number, y: number) Constructs a Vector2D object. |
Method Summary
Public Methods | ||
public |
Finds the result of addition with another vector. |
|
public |
Finds the "cross product" between this vector and another vector. |
|
public |
Finds the angle between two vectors (in degrees). |
|
public |
Finds the dot product between this vector and another vector. |
|
public |
Checks if this vector and another vector are equal. |
|
public |
projectOnto(vec: Vector2D): Vector2D Finds the vector projection of this vector onto another vector. |
|
public |
rotateDegrees(deg: number): Vector2D Finds the vector resulting from a rotation in degrees. |
|
public |
rotateRadians(rad: number): Vector2D Finds the vector resulting from a rotation in radians. |
|
public |
Finds the vector resulting from multiplication by a scalar. |
|
public |
Finds the result of subtracting another vector. |
Public Constructors
Public Members
public x: * source
public y: * source
Public Methods
public add(vec: Vector2D): Vector2D source
Finds the result of addition with another vector.
Params:
Name | Type | Attribute | Description |
vec | Vector2D | The vector to add. |
Test:
public cross(vec: Vector2D): number source
Finds the "cross product" between this vector and another vector.
Params:
Name | Type | Attribute | Description |
vec | Vector2D | Vector to find the cross product with. |
Test:
public degreesTo(vec: Vector2D): number source
Finds the angle between two vectors (in degrees).
Params:
Name | Type | Attribute | Description |
vec | Vector2D | Vector to find the angle to. |
Test:
public dot(vec: Vector2D): number source
Finds the dot product between this vector and another vector.
Params:
Name | Type | Attribute | Description |
vec | Vector2D | Vector to find a dot product with. |
Test:
public equals(vec: Vector2D): boolean source
Checks if this vector and another vector are equal. Returns true if the x- and y-components are equal.
Params:
Name | Type | Attribute | Description |
vec | Vector2D | Vector to compare with. |
Test:
public projectOnto(vec: Vector2D): Vector2D source
Finds the vector projection of this vector onto another vector.
Params:
Name | Type | Attribute | Description |
vec | Vector2D | Vector to project onto. |
public rotateDegrees(deg: number): Vector2D source
Finds the vector resulting from a rotation in degrees.
Params:
Name | Type | Attribute | Description |
deg | number | Angle (in degrees) to rotate. |
public rotateRadians(rad: number): Vector2D source
Finds the vector resulting from a rotation in radians.
Params:
Name | Type | Attribute | Description |
rad | number | Angle (in radians) to rotate. |