@dominicstop/utils
Version:
Yet another event emitter written in typescript.
58 lines • 2.31 kB
TypeScript
import { Cloneable } from "../types/Cloneable";
import { ValueRepresentable } from "../types/ValueRepresentable";
import { Angle } from "./Angle";
import { Point, PointValue } from "./Point";
export type Vector2DValue = {
dx: number;
dy: number;
};
export declare class Vector2D implements Cloneable<Vector2D>, ValueRepresentable<Vector2DValue> {
dx: number;
dy: number;
epsilon: number;
constructor(args: Vector2DValue);
get asValue(): Vector2DValue;
get asPoint(): Point;
get asPointValue(): PointValue;
get magnitude(): number;
get normalized(): Vector2D;
get isZero(): boolean;
get isUnit(): boolean;
get perpendicular(): Vector2D;
get inverse(): Vector2D;
/**
* Returns the angle in radians from the positive x-axis to the vector.
*/
get angle(): Angle;
clone(): Vector2D;
computeDistanceFromOtherVector(otherVector: Vector2D): number;
isEqualToOtherVector(otherVector: Vector2D, tolerance?: number): boolean;
addWithOther(other: Vector2D): void;
subtractFromOther(other: Vector2D): void;
multiplyByScalar(scalar: number): void;
divideByScalar(scalar: number): void;
normalizeInPlace(): void;
addedWithOther(otherVector: Vector2D): Vector2D;
subtractedWithOther(otherVector: Vector2D): Vector2D;
multipliedByScalar(scalar: number): Vector2D;
dividedByScalar(scalar: number): Vector2D;
dotProductWithOtherVector(otherVector: Vector2D): number;
/**
* Rotates the vector by a given angle in radians.
*/
rotateByAngle(angle: Angle): Vector2D;
projectOntoOtherVector(other: Vector2D): Vector2D;
angleBetweenOtherVector(other: Vector2D): Angle;
crossProductWithOtherVector(other: Vector2D): number;
reflectOverOtherVector(vector: Vector2D): Vector2D;
limit(maxMagnitude: number): Vector2D;
static get zero(): Vector2D;
static get one(): Vector2D;
static get unitX(): Vector2D;
static get unitY(): Vector2D;
static initFromAngle(angle: Angle, magnitude?: number): Vector2D;
static initFromPoints(p1: PointValue, p2: PointValue): Vector2D;
static computeAverage(vectors: Vector2D[]): Vector2D;
static distanceBetweenTwoVectors(vectorA: Vector2D, vectorB: Vector2D): number;
}
//# sourceMappingURL=Vector2D.d.ts.map