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`

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.