Skip to content

The surface maps a 3D curve to its UV curve, and curves do not depend on surfaces

ParametricSurface::curve_3d_to_uv(&self, curve: &Curve, tol) -> Result<Curve2D, Curve3DToUvError> gives the exact UV curve c of a 3D curve C lying on the surface S, in the same parameter: S∘c = C, so self.point_at(c(t)) is curve.point_at(t) for every t. It is the mirror of uv_curve_to_3d (ADR 0030), and it replaces the six inherent parametrize_on methods of Line, Circle, Ellipse, Parabola, Hyperbola and BSplineCurve. Curve3DToUvError replaces ParametrizeError, with the same variants: NotAnalytic and CurveNotOnSurface. The free sampled fallback parametrize_numeric becomes curve_3d_to_uv_numeric, re-exported at the crate root next to intersect_curve_surface.

The method has the same shape as uv_curve_to_3d. It is a provided method whose default refuses with NotAnalytic, so a surface type defined outside the crate keeps compiling. Each crate surface overrides it with a one-line forward to surfaces/uv_curve/from_curve.rs, and Surface and ElementarySurface forward through their variant lists (ADR 0017). It takes &Curve, so the trait stays dyn-compatible.

The closed forms live on the elementary surfaces. The table is unchanged: a line or circle on the plane, cylinder, cone, sphere and torus where its image is a 2D line or circle, and every conic or spline on a plane. The forward reads the surface through as_elementary, and every curve on an extrusion, revolution, B-spline or Bézier surface is NotAnalytic, as it was. curve_3d_to_uv_numeric samples those pairs. Mapping a curve onto the extrusion of a line, the mirror of ADR 0030's affine rows, has no consumer yet and is left out.

Taking &Curve adds Curve::Bezier. A Bézier curve in a plane maps its poles exactly as a B-spline does, since both are the same spline underneath. Its image is a BezierCurve2D with the same weights, and a pole off the plane gives CurveNotOnSurface. On every other surface it is NotAnalytic, as a B-spline is.

Curves do not depend on surfaces. With parametrize_on gone, no production file under src/curves/ names crate::surfaces, or any name that src/lib.rs re-exports from surfaces, as a whole word. The second ban closes the way back through the root re-exports, such as use crate::Plane;. tests/module_dependencies.rs reads the sources and fails on either. It builds the name list by parsing the pub use surfaces:: statements in src/lib.rs, so a new or renamed surface type is covered without editing the test. Test code, meaning tests.rs files and tests/ directories, may still build surfaces.

Considered options

  • Keep parametrize_on as a deprecated shim: rejected. The crate is pre-1.0, and the shim would keep the curves importing surfaces until it is removed. The migration is one line, given in the changelog.
  • A free function curve_3d_to_uv(curve, surface, tol): rejected. The surface owns both directions, as it owns point_at and parameters_of at point level.
  • Closed forms on the swept surfaces now: deferred until a consumer needs them. The numeric fallback answers in the meantime.

Consequences

Rust callers write surface.curve_3d_to_uv(&circle.into(), tol) for circle.parametrize_on(surface, tol), and match on Curve3DToUvError. A caller holding a Curve no longer dispatches on its variant. Python moves the method from the 3D curve classes to every surface class: surface.curve_3d_to_uv(curve, tol=None) accepts any 3D curve class, raises Curve3DToUvError, and geomcore.parametrize_numeric becomes geomcore.curve_3d_to_uv_numeric. The stub-only _ParametrizeOnMethods class is gone. The method is now part of _SurfaceMethods.

Amended (#186): curve_3d_to_uv_numeric is replaced by curve_3d_to_uv_within, one UV curve within a deviation; see the amendment to ADR 0035.

Amended (#221): the swept surfaces now have closed forms for their iso-curves, since the plane cuts of swept surfaces (ADR 0023) are their consumer. On an extrusion, a generator line maps to a line along v and the profile translated along the direction to a line along u. On a revolution, a parallel circle maps to a line along u and the profile turned about the axis to a line along v. The forward reads the surface through as_extrusion and as_revolution when as_elementary finds no elementary surface. A translated or turned profile is recognized on samples against the profile at the same parameters, so it must run in the profile's own parameter, as the cuts build it. Every other curve on a swept surface stays NotAnalytic. The cuts themselves set the curve on the swept surface from the parameters they already hold: the profile parameter of each crossing, and the angle of each meridian. Inverting a generator line's origin on an ellipse profile cost five times the cut. with_exact_uv_curves then fills only the slots still empty, whatever the method, so a curve through crossings found numerically, such as a plane cutting the extrusion of a spline profile, gets the plane's curve too.