38. Geometry standard library (spec/lib/geometry.md, 2026-11-21)
- 38.1 Two distinct point types:
Pt(exactInt) andVec(carefulF64). Integer and floating-point geometry have different safe operations:Pthas exact equality, lexicographicOrd,Hash,Show("x y"),unit_dir, and epsilon-free predicates;Vechasunit,scale,div,project,reflect, epsilon-parameterized predicates, and omitsShowto respect decision 1.5 (no bare float printing). Separating them keepsPtnon-generic instd.prelude(no default type parameters needed) and makes the exact-vs-approximate boundary visible in the type (p.to_vec). Reverse: unify intoPt<T = Int>if default type parameters and conditional impls land.
- 38.2 Exact orientation predicates compute cross and dot signs in
I128.dotandcrossstayIntfor arithmetic ergonomics, withdot128/cross128alongside;turn,ByAngle,ByAngleFrom,angle_less,same_dir,on_segment,segments_meet,locate,locate_convex, hulls, and Minkowski sums compute orientation signs inI128, eliminating silent 64-bit overflow up to1e18coordinates at negligible cost (imul64x64->128). Reverse: switch internal helpers back toIntcross/dot.
- 38.3 Options as named defaults and O(n) chain builders.
segments_meet(..., strict: Bool = false)andconvex_hull(..., collinear: Bool = false)avoid suffixed variants.lower_hullandupper_hulltake already(x, y)-sorted input in O(n) so divide-and-conquer hulls (ucup4s25e) stay O(n log n) alongsideminkowski_upper.locateandlocate_convexreturnLocation(Inside | Boundary | Outside) rather than1 / 0 / -1, andVec.rot(by: Vec)uses a named option instead of a_bytwin (coordinator round, §2). Reverse: returnIntor add a separate method.