2d-physics-engine
Version:
A lightweight, flexible 2D physics engine with ECS architecture, built with TypeScript
37 lines • 1.52 kB
TypeScript
export declare class Vector2 {
readonly x: number;
readonly y: number;
constructor(x?: number, y?: number);
/** Returns the magnitude (length) of the vector. */
getMagnitude(): number;
/** Returns the squared magnitude (more performant for comparisons). */
getSquareMagnitude(): number;
/** Returns a normalized vector (unit length). */
getNormal(): Vector2;
/** Returns a vector perpendicular to this one (rotated 90°). */
getTangent(): Vector2;
/** Scales the vector by the given scalar. */
scale(scalar: number): Vector2;
/** Returns a new vector representing this + other. */
add(other: Vector2): Vector2;
/** Returns a new vector representing this - other. */
subtract(other: Vector2): Vector2;
/** Returns a new vector representing this + other * scalar. */
addScaled(other: Vector2, scalar: number): Vector2;
/** Angle in radians between two vectors. */
radians(other: Vector2): number;
/** Component-wise multiplication. */
componentProduct(other: Vector2): Vector2;
/** Scalar dot product. */
dotProduct(other: Vector2): number;
/** Scalar 2D cross product. */
crossProduct(other: Vector2): number;
/** Rotates the vector by given radians. */
rotate(radian: number): Vector2;
/** Returns a copy of this vector. */
clone(): Vector2;
/** Static shorthand constructors. */
static zero(): Vector2;
static fromAngle(radian: number): Vector2;
}
//# sourceMappingURL=Vector2.d.ts.map