Bug report: ArcBlend may fail to close curves

Using ArcBlend to close a curve can result in non-closed curves in a small percentage of arc blend attempts.

Info

Rhino version: 7.30.23163.13001, 2023-06-12

This occurs with the following ArcBlend Options:

  • Trim=Yes Join=Yes
  • Trim=Yes Join=No

Examples

ArcBlendTrimmingBugs.3dm (63.5 KB)

The operation may “over-trim”, creating a gap of random width:

The gap can often be very small:

The operation may “undertrim”, creating a loose end:

Observations

The algorithm tends to over-trim when closing more complex curves. It tends to under-trim when the trimmed portion is large and runs tangent to the blend curve.

Both errors occur at random, depending on the geometry. The error rate is roughly 1 in 10 for the examples. In my daily use, this error happens at a similar rate.

Workarounds

I fix gaps with the Match operation plus occasional manual control point editing. I fix untrimmed sections with a Trim operation. When I miss the defects while drawing, I hunt them down during QC, using SelOpenCrv or the ShowEnds tool.

Impact of fix

Fixing the bug would reduce unnecessary operations and make arcblend easier to teach and use for our process. This would make the tool feel significantly more solid and dependable.

I suspect that arcblend uses a point-curve intersection solver that is nondeterministic and rarely freaks out and gives us wrong answers. I also suppose that it might be difficult to solve the instability in the intersection solver. However, the solver works most of the time, and the wrong solutions are very easy to detect.

Perhaps it’s enough to:

  1. Trim the curve
  2. Test that the trimmed endpoints match the blend curve’s endpoints
  3. Redo the trim operation if these points mismatch

Hi @max.suica I could not repeat it here with these examples. Both gave me a closed curve after trimming and joining (both in command as well as afterward)
Do you have other examples that you could share?

Hi @Gijs, thank you for your attention to this problem. Here are two simpler examples, using a 3 segment polyline. They are both of the overtrim variety, where the operation cuts too much from one of the input curves.

In the first configuration I move one endpoint to a random point
ArcBlendErrorGif0

In the second configuration I move both end points so that the two segments have nearly the same radius.

ArcBlendErrorGif1

It should replicate within at most a couple dozen tries. In some configurations it won’t occur at all, in some configurations it will every 3 to10 tries. Please explore a few different configurations - it is pretty easy to run into the issue once you know it’s there.

The arcblend generation is fine. But we incorrectly apply the trim point, based on a code path that triggers at random.

Potential causes:

  1. Maybe we we accidentally re-parameterize the curve before applying the trim point :crazy_face:
  2. maybe we give one parameter to the createarcblend function, but give a different parameter to the trim function
  3. Maybe the trim function uses a numerical solver that can underconverge at random.

Possible regression testing plan:

  1. Generate the polyline curve [0,0], [5,0], [5,5], [0,5]
  2. Apply 1000 random blend parameters between the first and last segment of the curve
  3. Assert that createarcblend and trim are called with identical parameters on identical curves
  4. Assert that the results are all closed

Outcomes:

  1. If some curves are open even though we always pass identical parameters, then the trim function is likely the culprit.
  2. If we do not pass the same values, there is a logic error in the arcblend command.

Possible mitigation:

  1. Add a validation step that verifies the curve is closed
  2. Rerun the trim operation from scratch if the curve is open

This mitigation works because the operation will eventually work if you retry it.

@max.suica I got it now, thanks
RH-75955 arcblend doesn’t trim correctly

Awesome! The work ticket now captures the most common kind of error:

  1. Gaps. The result is open with a visible gap.

There are two other kinds of open curve errors that affect my work:

  1. No Trim. The result is open where Arcblend didn’t trim one end of the curve.
  2. Degenerate Ends. The result is open with invisibly close endpoints - as close as 10^(-10) units

All errors occur at random.

This example shows all types of error. I marked Gaps in blue, No Trim errors in red, and Degenerate Ends cases in magenta.

Image:

3dm File:
ArcBlendTrimmingBugsII.3dm (128.8 KB)

Note the gap is in errors of type 3 is incredibly small, on the order of 10^(-10) units. Here are the endpoints for the second degenerate example:

[247.55910279243909, 54.745575237092815, 0]
[247.55910279219364, 54.745575237178031, 0]
              ^                  ^

I suspect the same trim solver component causes all 3 errors.

thanks @max.suica for your detailed tests, I’ve added those to the yt

RH-75955 is fixed in the latest WIP