Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A more perfect curve family #26

Open
raphlinus opened this issue Dec 30, 2022 · 0 comments
Open

A more perfect curve family #26

raphlinus opened this issue Dec 30, 2022 · 0 comments

Comments

@raphlinus
Copy link
Contributor

I've been feeling a bit stuck on moving this crate forward, because I feel the current draft is not perfect. I talked about that a bit in #25 but will summarize here. Basically, I feel the curves are very good for most of the parameter space, but there are a few areas in which they are not great, and I also had a feeling that some of the definitions were a bit arbitrary, lacking deep mathematical beauty.

Two specific areas that were not great:

  • A curve with high tension on one side and neutral tension on the other has a curvature dip in the middle, which I don't find appealing. It should be more like a spiral (or a semicubical parabola).

  • It can only go to a moderate degree of superellipticity (by setting tension low on the endpoints), even less than a cubic Bézier. Superellipses are extremely common in font design; classic fonts such as Eurostile, and Melior are directly inspired by them.

And the mathematical critiques:

  • There is a case analysis between >1 tension and <1 tension, with the Euler spiral in the middle. The math is pretty different in the two cases.

  • The curve family is not closed under subdivision, a property very closely related to "extensionality" in my thesis (also see related CAD 2009 paper). In addition to mathematical beauty, this affects the UI, as inserting a new subdivision point changes the existing curve.

I have considered it an open question whether extensionality (or subdivision closure) is a highly desirable property or one that can be sacrificed in a tradeoff with other properties. If the proposal in this issue succeeds, I believe that will resolve the question to the former.

The proposal, very simply, is to represent the curve as a Cesàro equation (curvature as a function of arclength) where curvature is a rational function consisting of a linear divided by quadratic polynomial, in other words:

$$\kappa(s) = \frac{as+b}{cs^2 + ds + e}$$

I have been experimenting with this some and find it promising, though haven't fully developed it. I can make some observations:

  • Subdivision is straightforward.

  • The family is characterized by the sign of c/e:

    • If $c/e &lt; 0$, there are two cusps (zeros of the denominator), corresponding to high tension. Tension is lowered by subdividing the full curve at a point away from the cusp.

    • If $c = 0$ and $d \neq 0$, there is one cusp. This corresponds to the case of high tension on one side and neutral tension on the other.

    • if $c = 0$ and $d = 0$, the curve is an Euler spiral.

    • if $c/e &gt; 0$, there is no cusp, but there is a curvature maximum, with curvature tailing to zero in the asymptotes. This corresponds to the superellipses.

  • There is in general one inflection point. This is the biggest difference from a cubic Bézier (which has two in the general case) and a 4-parameter Spiro (which has three).

  • Curvature is monotonic for much of the parameter space, which means that in usage in a spline, curvature extrema will generally be at knots. This is a desirable property, and one of the main flaws of Béziers in splines.

  • I'm fairly confident that this can be integrated analytically, resulting in a Whewell equation. There's a case analysis as above, with the result expressed in terms of $\tan^{-1}$ and $\log(1 + x^2)$ for $c/e &gt; 0$, and variations of $\tanh^{-1}$ for $c/e &lt; 0$.

This curve family has an appealing mathematical beauty, and there's a good chance it will work well in practice. It should definitely be investigated more fully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant