Elmo: A new command to rebuild curves in Rhino

We are excited to share Elmo, a new command to rebuild NURBS curves in 3D to a target control point count and degree. This command aims to preserve some of the good features of Rebuild while generating curves that match the global shape of the input curve with higher accuracy.

More specifically, Elmo’s job is to find good control point locations of a new, non-rational curve with a prescribed degree that minimizes the distance between the input and the rebuilt curve as much as possible. Elmo gives you additional control over the look of the control polygon of a curve, and helps you preserve kinks in the form of G1 or G2 discontinuities.

elmo_rhino_head_small_crop

Elmo is available in the latest Rhino WIP for Windows and MacOS, so please download it and take it for a spin! Please note that this is a work-in-progress command, and there are plenty of rough edges as such. However, we would like your feedback early on as we continue iterating on it towards a fully-fledged command in Rhino 9.

Inputs

If you play with Elmo, you will see that it exposes many of the same inputs that Rebuild does:

  • Curve: A curve to rebuild (we currently support 1 curve at a time).
  • Degree: The target degree.
  • Point Count: The desired number of control points.
  • Preserve End Tangents: Whether to preserve tangents at the curve endpoints. This option is only available for open smooth curves and for curves with kinks.
  • Delete Input: Deletes the input curve and replaces it with the rebuilt curve. The attributes of the input curve are transferred over.
  • Output To Current Layer: Bakes the rebuilt curve to the current layer, regardless of the precedence of the input curve.

Additionally, we have added 2 new experimental features that augment our curve reconstruction technology: Pretty Polygon and Split At Kinks. Interested in the details? Please read on.

Pretty Polygon

Pretty Polygon embellishes the distribution of the control polygon of a rebuilt curve. If you activate this command, the command will expose two extra inputs:

  • Equalize Segments Strength: It evens out the distance between consecutive control points.
  • Smoothing Strength: It smoothens the control polygon by trying to make triplets of consecutive control points collinear.

These Pretty Polygon parameters work like weighted modifiers, à la Kangaroo, whose strength can vary from None to High. It would probably be too restrictive to fix a unique set of equalizing and smoothing values that work for every possible curve. Therefore, we let you explore the configuration that works for your particular use case.

Please note that modifying the control polygon is at odds with tight curve reconstruction: changing the control polygon typically worsens the quality of the rebuilt curve. Consequently, increasing the strength of these modifiers, the prettier the control polygon might be, but the rebuilt curve will deviate more from the original curve; and vice versa.

Split at Kinks

Tangency and curvature discontinuities (a.k.a. kinks) are geometric features that are oftentimes important to keep to rebuild a curve at higher fidelity. Elmo helps you keep these discontinuities automatically if you toggle the Split At Kinks option on and fiddle with either of its two inputs:

  • Angle Tolerance: Set the minimum angle value in degrees to consider a G1 tangency discontinuity as a kink. If the angle at the kink is lower than the tolerance, it will not be considered as such. The command tolerance range is between 5 and 180 degrees.
  • Curvature Discontinuities: This is an on and off toggle. If activated, Elmo will look at the curvature graph of the input curve, and then break the curve at G2 discontinuities – that is, at the locations where the graph jumps. A canonical example: the junction between a line and an arc segment. This feature is unavailable if the input curve is a polyline.

Elmo outputs a single NURBS curve with fully multiple knots to preserve such discontinuities.

In general, Elmo will do its best to allocate the number of control points you specify across all the curve segments between kinks. The command will let you know if the target point count is too low for the number of kinks detected.

Examples

Here are a few examples that show Elmo in action. We focus on comparing this command’s output with that of Rebuild so that you can directly pinpoint the differences with its closest cousin in Rhino. Most of these examples have been posted by users here on Discourse.

1. Coarse-graining curves

Let’s start simple. Suppose you have a curve with 79 control points and degree 3, and you want to rebuild it with a) a lower degree 2 curve and b) only with only 3 control points, like in this post. Elmo adequately pushes the middle control point to the left side of the curve to improve the match to the original curve.

2. Preserving tangents in rational polycurves

Now, say you have a rational polycurve of degree 2 and 15 control points. You would like to raise the degree to 5, but also reduce the control point count down to 7 while preserving the original end tangents, like in this other post.

If you use Elmo, not only will you get a tighter new curve as output, but also one whose control polygon (the dashed lines in the background) is closer to the curve. In contrast, Rebuild produces a curve that is visibly far off from the original black curve, and whose control polygon simply blows up off the screen.

At this point, you might be extremely happy with the NURBS curve produced by Elmo, but you wonder if there exists a different arrangement of control points that will evenly space out control points to facilitate surface modeling (think loft or sweep) in downstream tasks. PrettyPolygon can help you alleviate that itch.

3. Modifying control points with Pretty Polygon

3A. Equalizing control polygon segments

The following figure shows the effect of applying 3 different values of Equalize Segments Strength on the rebuilt curve and its control polygon: None, Low, and High. We focus on comparing the distance between 3 representative pairs of control points on the curve polygon to illustrate how the distance between is equalized as the input strength of this parameter increases.

The first curve, on the left, is our reference and is equivalent to running Elmo with the Pretty Polygon feature disabled. If we turn that feature on and set the strength to Low, we observe that the difference in distance between the 3 pairs of control polygons we picked decreased a tad little. For example, the difference between pairs A and B decreases by 15%, from 31.7 to 27.6 units. But if we crank up the strength from Low to High, the difference between pairs A, B, and C is negligible, at only 1 unit at most (see the curve on the right).

You will notice that while we have been able to equalize the distances between control points, this accomplishment has been at the expense of the fit of the rebuilt curve in blue to the original curve in black. Life is a constant negotiation.

3B. Smoothing control polygons

Fairing control polygons is a bit more involved to explain, but the right intuition to have in mind is that this command option will strive to make every consecutive triplet of control points form a line.
In practice, every triplet battles the others to achieve colinearity, so the best possible outcome of this fight to benefit all triplets is to end up with a smoother version of the initial polygon. Let’s look at an example.

In the figure above, we illustrate how the control polygon changes as we increase the value of the Smoothing Strength parameter from None to High. Take for example the triplet formed by control points 1, 2, and 3. Elmo computes a tight reconstruction (in blue) of the input curve (in black), but the triplet (1,2,3) of the resulting curve oscillates from left to right compared to all the other control points. While the NURBS fit is optimal, some people might consider the zigzag an undesirable artifact because it might mess up with the curvature graph of the rebuilt curve.

To produce a smoother polygon, we can set the Smoothing Strength to Low. The triplet of control points (1,2,3) has been untangled and now it forms something closer to a line. Success.

Similarly to the Equalize Segments Strength component of Pretty Polygon, the higher the value of the Smoothing Strength, the more the rebuilt curve will deviate from the input, but the smoother the control polygon will be. This is showcased by the curve on the right, where the Smoothing Strength is High, and triplets (1,2,3) and (2,3,4) keep pushing inwards to find a happy state of equilibrium where each of them is as colinear as possible.

Once again, the right amount of strength to apply to embellish your control polygon will depend on your particular application. So we provide options to let you pick the amount of strength that best works for you.

4. Preserving discontinuities with Split At Kinks

4A. Maintaining tangency kinks with an angle tolerance

Now imagine that you are handed a polyline with 84 control points by your client, but you want to convert that curve into a cubic NURBS because your CNC machine would not accept anything else as input.

The polyline looks like a circle, but at closer inspection you notice that there are 2 little notches at the top and bottom that you want to keep to stay faithful to your client’s design (see the figure below, left).

You notice that you need a significant number of control points to rebuild the polyline and preserve the notches with regular Elmo (which might altogether defeat the purpose of rebuilding in the first place).

But if you turn Split At Kinks on, and set the Angle Tolerance to something like 30 degrees, Elmo becomes aware of the 6 kinks at the notches and performs the curve reconstruction while fully preserving them. In the figure above, we show the difference between setting Split At Kinks off (middle) and off (right) for the same point count: 18 control points and degree 3.

Standard Elmo evenly distributes the control points around the circle and captures the gist of the global shape with a single smooth curve, but it completely misses the notches – a tiny, and local feature. In contrast, Elmo with Split At Kinks activated correctly spots the kinks and then distribute the control points in a completely different way to capture both the circle and the notches. All curves are created equal.

4A. Breaking a curve at curvature discontinuities

A classic example where maintaining curvature discontinuities (G2) matters is when rebuilding a polycurve made of contiguous NURBS and line segments, and where the intent is to preserve the line segments, well, straight and linear after rebuild.

Compared to G1 kinks, G2 discontinuities are harder to spot at first glance. The best way to detect them is by turning on the curvature graph of the input curve. To illustrate this, consider the degree 2 polycurve shown in the top left corner in the figure below, which we have drawn with 4 arcs and 1 line.

Even if Split at Kinks were on and we input a stringent Angle Tolerance, the command would not be able to find any G1 kinks in the polycurve because all the curves share tangents at their end points. As a result, reconstructing the original polycurve with a degree 5 NURBS and 21 would result in single smooth curve, like the red curve in the middle of the figure above. Note that this is not an inadequate result by any means, but if you cared deeply about keeping those straight lines, Elmo will be underperforming here for ya’.

Let’s go ahead and toggle on the Curvature Discontinuities option under Split At Kinks. Elmo then breaks the polycurve into segments at the locations where the curvature graph jumps (the little yellow circles on the graph), rebuilds every resulting curve segment independently, and finally stitches all the reconstructed pieces together into a single NURBS. The curvature jumps in the input curve are preserved, and the line segment of the input polycurve is indeed a line of degree 5, as requested. No problemo [sic].

And while we worked with arcs and lines here, you can imagine that the same principle of G2 splitting applies to freeform NURBS curves connected by lines.

FAQs

A. Why does the command seem to freeze the first time I run it?

The command needs to install a few online dependencies and compile code the first time it is executed, but Elmo should run significantly faster the second time it is run.

B. Why Elmo?

This is a test name that pays homage to the original name of Rhino’s Rebuild, back in the olden days. We thought it would be fun to revive this name as we revisit the curve reconstruction technology. Rebuilt curves should be nice and friendly, just like Elmo.

Try It Now!

Elmo is available in Rhino WIP. Download it and give it a try.

74 Likes

Geez I was just gonna ask where I’d heard the name “Elmo” before, now I’m gonna go have an existential crisis.

1 Like

Thanks @pastrana

3 Likes

That’s what I was waiting since ages!
Good job.
Finally smtg new for the good modeling slide.
Love it :heart::heart::heart:

4 Likes

Awesome! :smiley: I am looking forward to test it!

2 Likes

Does this mean an offline installation of Rhino can’t use it? If so is this a planned permanent feature of the command or just something that exists during development?

:grinning: :smiley: :grin: :joy: :slightly_smiling_face: :wink:

This is huge. Curves can now frequently be rebuilt with fewer control points for a given maximum deviation compared to the old Rebuild. I have been waiting for an updated Rebuild for a very long time.

I assume Elmo will eventually show the "Maximum deviation before completing the command, and have options “Delete input” and “Create the new object on the current layer”.

Thank you!!!

7 Likes

I have been trying to code something like this myself for a minute. Glad to see the your amazing team getting it done better than I would haha.

Naming is such an over looked aspect of CAD programs. Will the final name be something descriptive (like rebuildIterative) or is the intent to keep the name Elmo? I ask because elmo a confusing and random name that will make rhino hard to use for new users and set a bad president for future new feature getting ultimately nonsense names (bad).

1 Like

The latter…

You never know - we kept the name “Rhino”…

7 Likes

Some of your questions and examples on curve rebuild helped steer the development of Elmo, so thanks for the continuous feedback, @davidcockey!

Yes, eventually we want Elmo to expose as many of the options that Rebuild does.

For now, yes. We have plans for making this not a requirement, but since this is a prototype, we are experimenting quickly and require internet for that experimentation.

Life used to be more fun back before we all had to be serious. A standard refrain among programmers references how hard naming is.

Elmo was the codename for Rebuild the first time it was written, I believe in the Rhino 3 epoch. That was a stressful time, and for some reason Dale Lear had a Tickle Me Elmo puppet in his office (this was a popular toy in the day that had an uncanny blend between a Poltegeist quality and fun stuffed friend). At any rate, since naming was hard, we went with Elmo.

Maybe someday this command will be RebuildBetter or RebuildIterative or BoringOldRebuild. But for now, you get Elmo.

7 Likes

According to Wikipedia, Elmo is venerated as the patron saint of sailors and abdominal pain. Should be good for marine architects and stressed Rhino users.

7 Likes

Believe it or not, that Elmo puppet is still alive in the office. It now sits next to me and watches me type :slight_smile:

6 Likes

It also never blinks; it is always watching you Rafael. :smiling_imp:

3 Likes

Because a Rhinoceros is the only REAL unicorn?

1 Like

…joking aside, this is awesome!!! thanks McNeel team!

G

29 Likes

This is great to see…I always found that the curve-fitting of Rebuild was not that great in certain situations, like making Illustrator-friendly (cubic Bézier) curves that are more precise/accurate. This lead me to Raph Levien’s work here and here. I don’t know if Elmo utilizes any of those optimizations, but perhaps those links could be helpful?

1 Like

I was just thinking on this more, could this actually be a setting in the rebuild command to switch between methods like how we switch between the different types of sweeping?

Also, I love the image of using the Tickle Me Elmo as a debugging duck. May he ever haunt your coding day-mares!

1 Like