Skip to content

A contact is read where its curve stays within confusion

The closed forms answer two surfaces near a contact with the topology of the contact: a tangent point, a tangent line or circle, a loop that crosses itself, two conics or two circles that cross. They used to decide it on the offset alone: surfaces within tol.confusion of touching were read as touching (#438, #439). Near a contact two surfaces part quadratically, so offset by ε along their common normal, the curve where they meet lies √(2ε / κ) from the contact point, κ their relative curvature across it. For ε near confusion that is far beyond it: a plane 5e-8 off a saddle level of a torus of radii 10 and 2 was answered with a crossing 1.3e-3 from the curve it stood for, and a thin cylinder 1e-7 from touching a thick one inside with a crossing 1e-3 from its two loops. Every point of those answers was within ε of both surfaces; the answer still was not within confusion of their intersection, nor of its topology.

A contact is now read where the curve of the surfaces as given stays within confusion of it: √(2 |ε| / κ) ≤ confusion, that is |ε| ≤ κ confusion² / 2. Beyond that, the closed form gives the curve of the surfaces as given: the parted or joined loops, the small loop around the contact, the two lines or circles a hair apart. The rule has one home, reads_as_touching in operations/intersect/exact/contact.rs, and every closed form asks it:

  • Where the surfaces stand apart, no curve near the contact, a gap within tol.confusion still reads as touching. The contact point is then within confusion of both surfaces and no curve of theirs is left out (ADR 0034). Where they pass through each other, or where the curve lies on both sides of the contact, a crossing that parts one way and joins the other, the offset counts by its size.
  • κ is the smaller principal curvature, in size, of one surface relative to the other at the contact: the eigenvalue nearest zero of the difference of their second fundamental forms read along a common normal. Each form is in closed form from the surface's shape, not its parameters: a sphere's pole or a cone's generator near the apex reads its curvature like any other point; only a cone's apex and a point on a torus's axis have none, and read as not touching. It bounds the curve's reach every way from a point contact. A contact along a line or a circle, of an elementary pair, takes the curvature across it in closed form: 1/r for a plane on a cylinder or a torus's top circle, 1/r1 ± 1/r2 for parallel cylinders or spheres.
  • An offset within its rounding reads as no offset: within 16 roundings of the lengths it is computed from and of the distances from where each surface is placed (a plane's origin, a cylinder's or a cone's frame origin, a sphere's or a torus's centre) to the contact. A surface's lengths are measured from that point, and turning it rounds the point and its directions, which moves the surface near the contact by up to the rounding of that distance: an exact contact between surfaces placed a thousand units from it still reads as one. The world origin plays no part, so moving the pair does not change the answer.
  • Two conics around a common sphere cross where the line through the circles where both surfaces touch the sphere meets it. A line within confusion of touching the sphere reads as touching it, the conics touching once, only where its two crossings, √(2 ρ ε) apart for a sphere of radius ρ and a line ε from touching, stay within confusion of the point: the same rule, the curvature across the sphere's. Spheres within confusion of one give conics within the spheres' gap of both surfaces; where the conics do not cross, they come nearest where both surfaces nearly touch the sphere and part slowly, and the gap over the sine of their angle there must stay within confusion.

The rule is invariant under similarities: ε scales with the model, κ inversely and tol.confusion with it (ADR 0051).

It amends ADR 0043 and ADR 0044 on one point: a factor of the discriminant within its touch tolerance of vanishing twice is read as touching only where it also passes this rule, the gap measured as before (r (1 − |cₖ|) for a cone and a cylinder, |Q| / |∇Q| for two cones, the tube circle's reach for a torus). Cylinders whose radii move to make a touch exact move them by no more than the rule allows.

Considered options

  • Keep the offset rule: rejected. It answers configurations a hair from a contact with a topology and a point thousands of confusions from their intersection, and a caller has no way to tell.
  • Report an Unseparated region where the closed form cannot tell the strands apart, as the curve–surface search does (#429): not needed. Every closed form that snapped already reads the parted or joined loops of the surfaces as given, each point exact; the fit (ADR 0036) follows their pinch like any other turn.
  • The larger relative curvature, or the one on the side of the offset: rejected for a single number. At a saddle the curve reaches √(2ε / κ) with κ of the offset's sign, and around an elliptic contact the loop's longer axis is set by the smaller curvature. The smaller one in size bounds both; the band it loses is a factor of the ratio of the curvatures, a few confusions squared over the radius.
  • Curve–curve and curve–surface hits: unchanged. A hit is a point, and ADR 0034 reads two curves within confusion over a stretch as one contact on purpose.

Consequences

At the default tolerance, κ confusion² / 2 is about 5e-15 κ, below the rounding allowance of any feature of unit size or more: in practice a contact reads as one only when its offset is within rounding, and the curvature term decides only at coarser tolerances or for small, sharply curved features. That is the rule doing its job, not a gap in it: data given to ten or twelve significant digits is a different pair of surfaces, and its curve is read as given. A sphere of radius 2 and a plane 1e-10 through it meet in a circle of radius 2e-5, two hundred confusions, where they used to give a tangent point; cylinders of radii 2 and 1 crossing at a right angle, axes 3 − 1e-12 apart, meet in a small loop 1.4e-6 across instead of at a tangent point. A caller whose data is rounded that far reads such contacts at a confusion of √(2ε / κ) or more: 2.5e-5 turns the sphere and the plane back into a tangent point. Likewise, turning a pair after moving it far from the world origin rounds where its surfaces are placed by the rounding of those far coordinates, and the pair is then a different one.

Within confusion of a contact, a result now depends on which side the surfaces are and by how much, and the loops near a contact may pass within 2√(2 confusion / κ) of each other. The fits of those loops take more segments near the pinch.

Amendment: the octic curves and a sphere holding a tube circle (#441)

The octic curves of a torus and a cylinder, a cone or a second torus off its axis, and a sphere holding a tube circle of a torus, now ask the same rule. They used to decide on the offset alone.

  • The octic curves read a point where the surfaces come within confusion of touching, a stationary point of the other surface's equation F on the torus's angles, as touching only where reads_as_touching says so: the gap to the other surface, read with the torus centred at the origin so that it does not carry the rounding of far coordinates, counts by its size where the curve runs around or through the point (F's Hessian indefinite, or of the sign opposite to F), and stands apart otherwise. Only those points are moved onto by the one move that makes them exact; the rest are left to the curve as given, whose tube circles turn back a hair from them. A second torus touching along a tube circle it shares is read as before (ADR 0050): its contact is a whole circle. Its other contacts, the points away from the circle where the quotient of F by 1 − cos(u − u₀) is stationary and within its bound, go through the same rule (#454), the gap and the side of the curve read the same way on the quotient, whose zeros are the rest of the curve; they used to be accepted on that bound alone, and the sweep then gave up on a point a few confusions from touching that it took for a crossing. The shared circle itself is looked for with the first torus centred at the origin, so that its points' normals do not carry the rounding of far coordinates.
  • A sphere holding a tube circle touches the torus along it only where its curve stays within confusion of the circle: centred δ out from the centre circle and h above its plane, of radius s wider than the tube, it passes s + δ cos v + h sin v through the torus at v around the circle, where the two bend apart by κ = R / (r (R + r cos v)) across it. The most it passes through, s + √(δ² + h²), against the least κ, R / (r (R + r)) at the outer equator, bounds how far the curve strays, and goes to reads_as_touching_across. Beyond that, the two tube circles it holds are read only where they stand for the curve, the gap over the sine √(q² − R²) / ρ of the angle they cross at within confusion, as for two conics around a common sphere. Otherwise the curve is a band of tube circles whose bounds, cos τ within the square of its width of one, rounding cannot tell apart, and the closed form gives the pair to the marcher (NotAnalytic), rather than an empty or loopless quartic. Just beyond confusion the general quartic reads that band (#452): it takes the roots of Δ in s = cos τ ∓ 1 from the end of [−1, 1] nearer them, where each coefficient is of the size of the band and the discriminant separating the roots is no longer below the rounding of terms of the torus's size.

Reading the curve as given near a contact put the points where a tube circle turns back a hair from it, and the subdivision that finds them lost them in two ways, both fixed: a zero on a side of its boxes, where a symmetric pair puts it at a multiple of a quarter turn, was dropped from both boxes by rounding, so the charts are now turned off those angles by 1/π; and Newton's steps at a zero where the two polynomials meet at a small angle stall at their rounding above 1e-12, so steps that stop shrinking within a zero's width are taken, provided both polynomials change sign a zero's width either way, which a double zero does not.