Module conic

Source
Expand description

Conics: exact line/conic and conic/conic intersection.

A conic is A x^2 + B xy + C y^2 + D x + E y + F = 0 with exact dyadic coefficients; circles and ellipses built from f64 data are exact.

§Line meets conic

Along p(t) = from + t*d the conic is a quadratic in t, so a hit is a Root2 and everything crate::root decides applies: exact tangency, exact ordering along the line, across different conics.

§Conic meets conic

Up to four points whose coordinates are, in general, roots of a quartic that radicals cannot express usefully. They are computed the way CGAL’s algebraic kernel does it:

  1. Shear u = x + k*y for a small integer k, chosen so no two intersection points share u (finitely many k are bad).
  2. Eliminate y: the resultant R(u) has the points’ u as roots.
  3. The common root in y is rational in u: y = N(u) / D(u) from the first subresultant, valid because the shear made D(u) != 0 at every real root.
  4. Each point is a RealRoot u0 plus those polynomials. Exact coordinates as RealRoots follow from a second resultant, and the sign of any conic or line at the point is the sign of one polynomial at u0.

Tangency is exact: in sheared coordinates the intersection multiplicity at a point is the multiplicity of u0 as a root of R.

Structs§

Conic
A x^2 + B xy + C y^2 + D x + E y + F = 0, coefficients exact.
ConicLineHit
One exact hit of a line with a conic: t = (-beta +- sqrt(disc)) / alpha on the line, or t = -gamma / (2 beta) in the linear case.
ConicPoint
One exact intersection point of two conics.

Enums§

ConicIntersection
How two conics meet.
ConicLineHits
Where a line meets a conic.

Functions§

conic_intersections
Exact intersection of two conics.
line_conic_hits
Exact intersection of a line with a conic.