Types - Core2d
API reference for ./geometry/core2d on @huukhanhnguyen/types.
See the Guide for the package's role.
API reference
Signatures are generated from the live package .d.ts - not hand-written.
Axis2d
type
The plane twin of Axis (core.ts) (OCCT gp_Ax2d precedent).
type Axis2d
// = {
origin: Point2d;
direction: Vector2d;
}BoundingBox2d
type
Axis-aligned box in 2D. Same stem as geometry BoundingBox2d ops namespace. Plane twin of bare BoundingBox (core.ts). Component fields match clip/window call sites and the flat wasm wire [minX,minY,maxX,maxY] field order.
type BoundingBox2d
// = {
minX: number;
minY: number;
maxX: number;
maxY: number;
}Point2d
type
2D point. Plane twin of 3D bare Point (core.ts).
type Point2d
// = [number, number]Transformation2d
type
A flat 2D affine transform, 6 numbers [a, b, c, d, tx, ty] — byte-for-byte the kernel's Matrix3x2 = [f64; 6] (crates/geometry/src/types.rs), so this type crosses the wasm boundary with NO conversion. It is also the CSS/SVG matrix(a, b, c, d, tx, ty) convention.
Layout is column pairs: the linear part's columns are (a, b) and (c, d), and (tx, ty) is the translation. Points are COLUMN vectors:
x′ = a·x + c·y + tx
y′ = b·x + d·y + tyIdentity is [1, 0, 0, 1, 0, 0]. Composition follows column-vector order: the kernel's transform2d_multiply(A, B) applies B first, then A (the result maps p → A·(B·p)). The linear part's determinant is a·d − b·c; |det| = 0 is degenerate and has no inverse.
Unlike Transformation (core.ts, whose major order is stated per use), the layout here is FIXED — there is exactly one 2D convention in the repo because the kernel's wire encoding fixes it. A 2×2 nested spelling and a packed Float64Array were both tried in-repo (scene's hatch helpers, model's deleted Transform2dMatrix) and folded here: one object, one definition. A hatch's lattice basis is NOT this object — it is a pair of spanning vectors ([Vector2d, Vector2d], a Bravais-lattice generator); the placement transform is DERIVED from it as translate(o) · scale(s) ·
rotate(θ) · B.
type Transformation2d
// = [number, number, number, number, number, number]Vector2d
type
Free 2D vector (direction). Same layout as Point2d; field role differs.
type Vector2d
// = [number, number]