Skip to content

Smoother splines than catmull-rom? #8329

@davepagurek

Description

@davepagurek

Topic

@dhowe was mentioning to me that sometimes when making shapes with splineVertex, you end up with sharp-looking edges where one wouldn't expect it. e.g. on the right here:

Image

This happens because the bezier equivalent of catmull-rom curves puts control points on either size of a given by going +/- one sixth of the distance from the previous to the next point (scaled up or down by the tightness parameter.)

Image

This means that the bezier control points will be an equal distance on either side, which generally looks OK but breaks down when the distance to the next point is a lot larger than the distance to the previous point.

However, we don't need them to be equidistant. It'll still look continuous as long as they lie on the same line. So one thing we could do make the distance on each side relative to just the distance from the middle to the next or to the previous point.

Image

This gives us something like the following:

Image

I have a little demo here where you can click to add points. When asymmetric tangents are allowed, that's the updated version: https://editor.p5js.org/davepagurek/sketches/TYV8cCxze

Is something like this significant enough to be worth considering? It's a subtle but still breaking change. We've talked in the past about having different splineMode()s, of which this could potentially be one. (Possibly as an addon if scaffolding for adding spline modes is added in core?)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions