UNPKG

@hiddentao/clockwork-engine

Version:

A TypeScript/PIXI.js game engine for deterministic, replayable games with built-in rendering

68 lines 2.16 kB
export declare class Vector2D { x: number; y: number; constructor(x: number, y: number); add(other: Vector2D): Vector2D; subtract(other: Vector2D): Vector2D; scale(scalar: number): Vector2D; dot(other: Vector2D): number; length(): number; distance(other: Vector2D): number; normalize(): Vector2D; rotate(angle: number): Vector2D; /** * Calculate the angle of this vector in radians * @returns The angle in radians [-PI, PI] */ angle(): number; /** * Calculate the angle between this vector and another vector * @param other The other vector * @returns The angle in radians between the two vectors */ angleBetween(other: Vector2D): number; clone(): Vector2D; toString(): string; /** * Serialize this Vector2D to a plain object */ serialize(): { x: number; y: number; }; /** * Deserialize a plain object to a Vector2D */ static deserialize(data: { x: number; y: number; }): Vector2D; /** * Calculate distance between two vectors */ static distance(v1: Vector2D, v2: Vector2D): number; /** * Calculate squared distance between two vectors (more efficient for comparisons) */ static distanceSquared(v1: Vector2D, v2: Vector2D): number; /** * Check if two positions are within a specified distance of each other * @param v1 First position * @param v2 Second position * @param distance Maximum distance between positions * @returns True if the positions are within the specified distance */ static isWithinDistance(v1: Vector2D, v2: Vector2D, distance: number): boolean; /** * Normalize angle to (-PI, PI) range */ static normalizeAngle(angle: number): number; /** * Calculate the shortest angle difference between two angles * @param angle1 First angle in radians * @param angle2 Second angle in radians * @returns The shortest angle difference in radians */ static angleDifference(angle1: number, angle2: number): number; } //# sourceMappingURL=Vector2D.d.ts.map