2d-physics-engine
Version:
A lightweight, flexible 2D physics engine with ECS architecture, built with TypeScript
45 lines • 1.87 kB
TypeScript
import { Vector2 } from './Vector2';
/**
* Axis-Aligned Bounding Box (AABB).
* Always normalized: min.x <= max.x and min.y <= max.y.
*/
export declare class AABB {
readonly min: Vector2;
readonly max: Vector2;
constructor(min: Vector2, max: Vector2);
/** ---------------- FACTORY HELPERS ---------------- **/
/** Create AABB from center and half-size. */
static fromCenter(center: Vector2, halfSize: Vector2): AABB;
/** Create AABB from minimum corner and width/height. */
static fromMinSize(min: Vector2, width: number, height: number): AABB;
/** ---------------- GEOMETRY GETTERS ---------------- **/
get width(): number;
get height(): number;
get size(): Vector2;
get center(): Vector2;
get area(): number;
get perimeter(): number;
/** Length of the diagonal. */
get diagonal(): number;
/** Returns true if width or height is zero (degenerate box). */
get isEmpty(): boolean;
/** ---------------- OPERATIONS ---------------- **/
/** Moves the AABB by a vector. */
move(offset: Vector2): AABB;
/** Expands or shrinks the bounds by a margin. */
expand(margin: number): AABB;
/** Returns a copy of this AABB. */
clone(): AABB;
/** ---------------- CONTAINMENT & INTERSECTION ---------------- **/
/** Checks if a point is inside the bounds. */
containsPoint(point: Vector2, inclusive?: boolean): boolean;
/** True if two AABBs overlap or touch. */
intersects(other: AABB, inclusive?: boolean): boolean;
/** Returns true if `other` is entirely inside this AABB. */
contains(other: AABB, inclusive?: boolean): boolean;
/** Returns a new AABB which encloses both boxes. */
union(other: AABB): AABB;
/** Returns intersection AABB or null if none. */
intersection(other: AABB): AABB | null;
}
//# sourceMappingURL=AABB.d.ts.map