Is there a command to find the ‘average’ or ‘middle’ curve between two curves…? I want to find the centre line between these two curves - the north and south extents of the Thames

TIA

Is there a command to find the ‘average’ or ‘middle’ curve between two curves…? I want to find the centre line between these two curves - the north and south extents of the Thames

TIA

thanks @DanielPiker.

Unfortunately the black line is the best I can achieve with the Tweencurves command - using MatchMethod=SamplePoints; SampleNumber=10000

The most accurate way to create an average curve between two input curves is to use Loft and extract the middle isocurve of the resulting lofted surface. Both of your curves pictured above appear as if they include multiple self-intersections, so this may be a challenge.

1 Like

Well, not really. it might only work OK, if both curves has exactly the same number of control points so that Loft could match them, but that is rare.

For these kinds of curves, there is no good automatic solution. The way to get something more or less workable is to draw a straight line between one pair of ends, then use Sweep2. While in the command, use AddSlash in as many places as necessary to get a decent flow of the isocurves between the two input curves - you many need dozens for complex curves. Once you are satisfied, accept the Sweep2 results, *then* extract the middle isocurve in the long direction.

Even so, something like below will never work, no matter how many slashes you add… It’s just not possible to connect the two curves with straight lines in a logical way, so you would need to ‘eyeball’ some kind of compromise solution, perhaps by doing the above and cutting out the bad parts and replacing them with hand-drawn segments.

I would take one of the curves, and then sample it with points, then find the closest point to the other curve, and take the average:

2 Likes

I wrote “The most accurate way”, because it’s exactly that. Loft works perfectly fine with curves consisting different amount of control points. The main problem in the two curves of the author is that they are overly-complex, so it’s nearly impossible to get a nice looking intermediate curve.

I disagree. Loft creates isocurves between points at equal fractions of the parameter range of each curve, which are not necessarily closest points or similar. (Based on testing and observation, not knowledge of the code.) The parameterization of a curve may or may not be related to the arc length of the curve.

Depending on the shape, structure and parameterization of the curves using the middle isocurve of a Loft surface may or may not be close to the “average” of the two curves. I have used this method with appropriate curves, but would not rely on it in general,

And that is without considering the question of what exactly is meant by the “average curve”.

“Loft” is the tool that creates the exact average between two curves/surface edges. Just because the outcome is not looking good does not mean it’s not average. On contrary, the “Add slash” option of “Sweep 2 rails” may result into achieving a controlled, slightly more “likeable” output surface, though this is NOT average, because its shape is adjusted manually.

One way to look at this is as trying to find a new curve for which all points have their closest point on the 2 input curves an equal distance away.

Here’s a way using Grasshopper to do a simple sample and sort to find this

avgcrv.gh (12.5 KB)

3 Likes

Note that this approach still needs a very rough approximation of the curves to get the lines to search along.

Using simple straight lines above and below will work to get rid of the inlets, but will mess up in regions where the whole river doubles back on itself.

Whereas drawing a guide curve above and below gives the right result

Actually, easier than providing upper and lower curves is to give a single very rough approximation to the centerline, then search along the perpendiculars for the points at equal distance to the input curves.

avgcrv2.gh (19.6 KB)

2 Likes

I was also thinking about fitting in some circles and running a line through their centers:

avg_circles.gh (9.9 KB)

2 Likes

Ah yes, good idea! The center of a circle tangent to both sides is the same as a point equidistant from them, but this way by making use of the tangent circle solver you avoid needing that sampling with the line approach.

disadvantage though is that you need a better approximated centerline, and at the ends it can go wrong, but also you see when increasing the point count, that some circles go out of the curves. Do you have a solution for that?

Another option would be to sample the distance field on a mesh then take contours

(this is with smoothing, but I can modify it to simply take shortest distances, which is simpler)

1 Like

@Gijs and @DanielPiker all these solutions are the same as Medial Axis. But I have to use Shortest Walk to get the center. As medial Axis is for a closed curve and not 2 separate curves.

4 Likes

Here’s the mesh sampling/contouring approach by simple equal distance without smoothing

interpcrvs_river2.gh (18.7 KB)

and the version with smoothing

interpcrvs_river.gh (22.8 KB)

4 Likes