Documentation
¶
Overview ¶
Package geomath holds the arithmetic of lib/geo's segment intersection on plain coordinates, so that lib/shape and the layout code can intersect segments without allocating points or slices. The expressions are lib/geo's, unchanged, so every result has the same bits.
geo.ComputeIntersections (Bézier curves) deliberately stays as it is: a restructured copy of it (arrays instead of slices) computed the same bits in normal builds but not in race-instrumented ones on arm64, where FMA contraction is decided per function by the compiler.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FirstBoxIntersection ¶
FirstBoxIntersection is the first point of geo.Box.Intersections(s) for the box with top-left corner (x, y), width w and height h and the segment s from (sx, sy) to (ex, ey): the sides top, right, bottom and left, from the top-left corner clockwise, each tested as IntersectionPoint(s.Start, s.End, side start, side end) is.
func SegmentIntersection ¶
SegmentIntersection is geo.IntersectionPoint on coordinates: the point where the segments u0-u1 and v0-v1 intersect, and whether they do.
The expressions are geo.IntersectionPoint's and so are the fused operations the compiler makes of them, so every result that is not NaN has the same bits: IEEE addition and multiplication are commutative except for which NaN operand a NaN result carries. That choice follows the operand order of the compiled instructions, which the compiler picks per function and picks differently here (on arm64 for s*udx, s*udy and udx*uvdy; on amd64 for s*udy and both additions). The result is NaN exactly when a NaN reached it, and the comparisons that decide whether there is an intersection do not depend on NaN payloads, so a NaN result is computed again by geo.IntersectionPoint itself, which gives the original's bits.
Types ¶
This section is empty.