API reference

Every public class, method, and event in @codexo/exojs. Generated from source.

C

classVector

@codexo/exojs / math / stable

Concrete mutable 2D vector with full AbstractVector arithmetic and ShapeLike collision support (treated as a point collider). `Vector.temp` provides a shared scratch instance for intermediate calculations — never store the reference across frames. `Vector.zero` and `Vector.one` are read-only sentinel constants. The four static factory methods (`add`, `subtract`, `multiply`, `divide`) always allocate a new `Vector`. Instance methods mutate in place and return `this` for chaining.

9
props
30
methods
0
events
Import
import { Vector } from '@codexo/exojs'

Concrete mutable 2D vector with full AbstractVector arithmetic and ShapeLike collision support (treated as a point collider).

`Vector.temp` provides a shared scratch instance for intermediate calculations — never store the reference across frames. `Vector.zero` and `Vector.one` are read-only sentinel constants.

The four static factory methods (`add`, `subtract`, `multiply`, `divide`) always allocate a new `Vector`. Instance methods mutate in place and return `this` for chaining.

Constructors 1
new(x: number, y: number): Vector
Methods 30
add(x: number, y: number): this
clone(): this
collidesWith(_target: Collidable): CollisionResponse | null
contains(x: number, y: number): boolean
copy(vector: Vector): this
cross(vector: T): number
destroy(): void
distanceTo(vector: T): number
divide(x: number, y: number): this
dot(x: number, y: number): number
equals(__namedParameters: Partial<T>): boolean
getBounds(): Rectangle
getNormals(): Vector[]
intersectsWith(target: Collidable): boolean
invert(): this
max(): number
min(): number
multiply(x: number, y: number): this
normalize(): this
perp(): this
project(axis: Vector, interval: Interval): Interval
rperp(): this
set(x: number, y: number): this
subtract(x: number, y: number): this
transform(matrix: Matrix): this
transformInverse(matrix: Matrix): this
add(v1: Vector, v2: Vector): Vector
divide(v1: Vector, v2: Vector): Vector
multiply(v1: Vector, v2: Vector): Vector
subtract(v1: Vector, v2: Vector): Vector
Properties 9
collisionType: CollisionType
x: number
y: number
one: Vector
zero: Vector
angle: number
length: number
lengthSq: number
temp: Vector
Source