Learn · Hidden Machines · Part VII
budding
Every Number Needs a Unit and a Home
Quantity types, affine frames, and region algebra.
You will distinguish quantities from coordinates, make transforms explicit, and model interaction targets as regions rather than points plus magic padding.
Twelve of what, measured where?
A duration API adds 500 milliseconds to 2 seconds as if both were raw numbers. A drag handler compares a document coordinate with a viewport coordinate. Arithmetic accepts both operations; meaning rejects them.
Quantity types pair magnitude with a unit. Addition requires compatible units; multiplication derives a new dimension. Coordinates need more: points belong to affine frames and cannot be added to points. A displacement may be added to a point, and a transform maps points between frames.
Hit testing operates on regions. A point belongs to a target region after the point and region share a frame. Tolerance is a named dilation of the region, not unexplained arithmetic sprinkled through handlers. Transforms map the whole region so scale and rotation do not silently invalidate interaction.
Where the model stops
Do not create a public type for every local scalar. Units and frames earn types where values cross boundaries or confusable quantities meet. Approximation, rounding, and device pixels remain explicit policies rather than geometry laws.
Lessons
- Primitive numeric equality erases units and provenance.
- Points belong to affine frames; displacements relate points.
- Transforms precede cross-frame comparison.
- Interaction targets are regions with explicit tolerance operations.
Practice
- Classify point-plus-point, point-plus-displacement, and point-minus-point.
- Trace a viewport pointer through scroll and scale transforms.
- Transfer dimensional types to bytes versus elements or radians versus degrees.
The final part turns recurring evidence like mixed coordinate arithmetic into advisory recognition signals.
References
- “W3C, “CSS Transforms Module Level 1”.” — coordinate systems and transformation matrices on the web.
- “W3C WAI, “Understanding Success Criterion 2.5.8: Target Size”.” — the accessibility consequence of treating targets as usable regions.