Implement ParamCurveDeriv for Arc - #557
Conversation
This solves a small part of linebender#556. Namely: being able to get at the tangents of an `Arc`. Similar to how e.g. `CubicBez::deriv` returns a `QuadraticBez` as a curve or how `Line::deriv` returns `ConstPoint` as a degenerate curve, even though the derivative actually is a tangent mapping, this implementation returns `ArcDeriv` as a curve. Numerically this implementation and the previous implementations are sound, but `ParamCurveDeriv` itself is muddying semantics a bit. We do document that already. `ArcDeriv` is closed under repeated differentation. Implementing `ParamCurveDeriv` gives the ability to use the result as a real object. Like the existing implementations, this makes it possible to find the second, third, etc., derivatives. You can compute the second derivative of an `Arc` as `let arc_deriv2 = arc.deriv().deriv()`, and use it to get at, e.g., the arc's curvature. There's more detail in the discussion of the [PR that triggered this](linebender#556), thinking of cleaner traits/types, and perhaps ways to get at tangents for curves that can't cleanly implement `ParamCurveDeriv`. This current PR intentionally does the simplest thing to make `Arc` differentiable.
|
I've spent the last 2 days arguing about this with myself. This has the advantage that some more code can work with arcs. Should Should it have the same derives as our other similar types? Should Arc now impl ParamCurveCurvature? Should there be a test for an arc with negative sweep? |
Yes (it is currently pub). With the current structure it has to be, otherwise
Perhaps we should. If we do that and start treating an For simplicity, I'm slightly in favor of dropping
Probably, yes. (As a separate discussion, it would be nice if
Yes. |
|
I'd also lean in favor of it just being I also agree that an acceleration structure for curvature would be worthwhile. I've been doing my own for the parallel curve work. But probably orthogonal to this PR. |
|
It's now just We can do the
👍️ |
This solves a small part of #556. Namely: being able to compute the tangents of an elliptical
Arc.Similar to how e.g.
CubicBez::derivreturns aQuadraticBezas a curve or howLine::derivreturnsConstPointas a degenerate curve, even though the derivative actually is a tangent mapping, this implementation returnsArcDerivas a curve. Numerically this implementation and the previous implementations are sound, butParamCurveDerivitself is muddying semantics a bit. We do document that already.ArcDerivis closed under repeated differentation.Implementing
ParamCurveDerivgives the ability to use the result as a real object. Like the existing implementations, this makes it possible to find the second, third, etc., derivatives. You can compute the second derivative of anArcaslet arc_deriv2 = arc.deriv().deriv(), and use it to get at, e.g., the arc's curvature.There's more detail in the discussion of the PR that triggered this, thinking of cleaner traits/types, and perhaps ways to get at tangents for curves that can't cleanly implement
ParamCurveDeriv. This current PR intentionally does the simplest thing to makeArcdifferentiable.