@huukhanhnguyen/types / geometry/core2d
geometry/core2d
Axis2d
The plane twin of Axis (core.ts) (OCCT gp_Ax2d precedent). Wasm kernel wire is flat [px, py, dx, dy] (crates/geometry/src/types.rs Axis2d) — convert at the door (catalog/axis2d.ts).
direction
direction:
Vector2d
origin
origin:
Point2d
BoundingBox2d
BoundingBox2d = {
maxX:number;maxY:number;minX:number;minY:number; }
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.
maxX
maxX:
number
maxY
maxY:
number
minX
minX:
number
minY
minY:
number
Point2d
Point2d = [
number,number]
2D point. Plane twin of 3D bare Point (core.ts).
Transformation2d
Transformation2d = [
number,number,number,number,number,number]
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 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.
Vector2d
Vector2d = [
number,number]
Free 2D vector (direction). Same layout as Point2d; field role differs.