geomath

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2026 License: MPL-2.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func FirstBoxIntersection(x, y, w, h, sx, sy, ex, ey float64) (px, py float64, ok bool)

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

func SegmentIntersection(u0x, u0y, u1x, u1y, v0x, v0y, v1x, v1y float64) (x, y float64, ok bool)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL