Expand description
Unit vectors, with the invariant enforced by the type.
A Direction is always unit length. Every constructor normalizes and can
fail; there is no way to build one from components without that check.
This matters more than it looks. Surface normals, axis directions and parameterization references are all directions, and an algorithm that assumes unit length (as almost all of them do, implicitly, when they skip a division) silently produces scaled results when handed a vector that is not. Making the invariant unrepresentable-if-false removes the whole class.
Structsยง
- Direction
- A unit vector in space.
- Direction2
- A unit vector in the plane.