Skip to main content

Module geometry

Module geometry 

Source
Expand description

The geometry of sketch entities, generic over Scalar so every formula serves both the residuals (differentiated with crate::dual::Dual) and plain evaluation (profiles, rendering).

An arc is stored as (start, end, sweep). Its signed curvature follows from those as k = 2 sin(sweep / 2) / |end - start|, so (start, end, sweep) and (start, end, curvature) describe the same arc — but only the sweep is smooth through a straight arc (k = 0) and a half circle, and only the sweep tells a major arc from the minor arc with the same curvature. The formulas below are written in the half sweep θ and never divide by sin θ where avoidable, so a nearly straight arc stays well-conditioned.

Every division and square root here is fallible — [Scalar::div] and Scalar::sqrt refuse a divisor or radicand that could be zero/negative — so a degenerate configuration (a zero-length chord, a collapsed arc) surfaces as a GeopResult error instead of silently producing an inf/nan that would then have to be caught downstream.

Structs§

Arc
A circular arc from s to e, turning counter-clockwise by 2 * half (clockwise if negative).
V
A 2-D vector.

Functions§

line_distance
Signed distance of p from the line through a and b, positive on its left.