Converting Curve to Arcs (with rounding arc radius)

Hi,

I’m trying to convert 2D nurbs curve to series of arcs, but the arc radius has to be rounded to a multiple of 100mm due to construction requirement. (I’ve attached the nurbs curves sample I would like to convert)
curves.3dm (93.7 KB)
Also, I would like to be able to control the number of arcs.

I’ve read through some of the discussions I could find in the forums, but non of them seems to work with this radius limitation.
I like how Fred made an optimization for the positions of segments on the curve here,
but this also doesn’t work with the rounded radius because each arc is constructed from two end points and two tangent vectors, which has no control on radius at all.

I can think of running some loops from one end to the other, but this may be too much (Galapagos + loop), as I wish to run this script on multiple curves at the same time too…

I hope my question makes sense.
Thanks ahead.

1 Like

My current attempt:

I dragged the second curve away from the first curve to see the dimensions.

Red segments are lines where the camber is above a certain value…

The curves are divided regularly, rebuilt as polylines and removed the least significant vertices of the polylines.

I used a script by @Mahdiyar to create 2-point arcs with rounded radii and finally chose the ones which fit best.

curve_to_rounded_arcs_and_lines.gh (34.9 KB)

2 Likes

@martinsiegrist
Hi Martin, thank you for the answer.
It’s crazy how quickly made this amazing script…!!

I spent some time to understand your GH. Please correct me if I’m wrong.
What your script is doing is

  1. make points on curves with removing some non-significant vertices.
  2. for each of the segment, you generated two arcs calculated from both sides of the segment.
  3. rounding the radius of these arcs, create four circles passing through the end points.
  4. pick one of the circle that has the least deviation.
  5. check the deviation of each mid point from straight line, and pick “line” or “arc” with a threshold.
  6. trim the circle for arcs.

I was struggling to get tangent continuity between arcs, but your solution seems enough for my purpose. I think this is a great way to generate approximate arcs!!
I still wonder if there’s any way to optimize the segmentation though.

Thanks again for your help, Martin.

It’s a nice challenge :slight_smile:

My definition does a little more. It takes three points to create the initial arcs. The point count of the reduced polyline can vary, so I shifted the points list twice to get three sets of points. I split the arcs at the second point and inserted an empty item at the start of one list and the end of the other so the lists line up. Sorry it’s complicate to explain in words. The first branch has just one arc, so does the last one. All other branches have two arcs. Since the 2-point arc script does not have a direction input, we get two arcs for each input. That means two arcs for the first and last branch and four for all branches in between. Out of those, the best fitting arc is filtered by sorting the distance from the arc midpoint to the initial curve you provided. Arcs with a camber less than a threshold are replaced with lines.

I have another solution in mind but I need some time.

Here’s the file from above with a Kangaroo approach added to it. It’s not very stable. At the end on the right side you can see how much the arc midpoints are away from the initial curve. Also these arcs are not tangent. I did not replace the nearly straight curves with lines yet.

curve_to_rounded_arcs_and_lines.gh (73.6 KB)

1 Like

@martinsiegrist
This is super interesting. Thanks again for the idea…!!
I think I understood the first solution quite well. The second one sort of optimized the process.
It’s really close to what I was hoping… Thanks!

The only thing is that the spline is still too segmented and The seam is quite visible. It is better if we can reduce the segmentation way more, even with more deviation from the original spline curve.
So in that way, do you think the Galapagos solution done by Fred Becquelin [here] may have some possibilities?
I’ve attached the GH file.
20221212_splineToArc.gh (20.5 KB)

In this way, the number of arcs is dramatically reduced. If there’s a way to take this solution with rounding radius, it would be great… It can deviate and modify the original line in some extent (This can be controlled by the number of gene)
Seeing how you used Kangaroo, I can also see the possibility to do with it, instead of using Galapagos though!

Sorry I can’t help you with this Galapagos approach.