RhinoPython Primer

Page 76

8.7 Nurbs-curves Circles and arcs are all fine and dandy, but they cannot be used to draw freeform shapes. For that you need splines. The worlds most famous spline is probably the Bézier curve, which was developed in 1962 by the French engineer Pierre Bézier while he was working for Renault. Most splines used in computer graphics these days are variations on the Bézier spline, and they are thus a surprisingly recent arrival on the mathematical scene. Other ground-breaking work on splines was done by Paul de Casteljau at Citroën and Carl de Boor at General Motors. The thing that jumps out here is the fact that all these people worked for car manufacturers. With the increase in engine power and road quality, the automobile industry started to face new problems halfway through the twentieth century, one of which was aerodynamics. New methods were needed to design mass-production cars that had smooth, fluent curves as opposed to the tangency and curvature fractured shapes of old. They needed mathematically accurate, freely adjustable geometry. Enter splines. Before we start with NURBS curves (the mathematics of which are a bit too complex for a scripting primer) I'd like to give you a sense of how splines work in general and Béziers work in particular. I'll explain the de Casteljau algorithm which is a very straightforward way of evaluating properties of simple splines. In practice, this algorithm will rarely be used since its performance is worse than alternate approaches, but due to its visual appeal it is easier to 'get a feel' for it.

Subsequent steps of the de Casteljau algorithm B

D

Given only the coordinates {A; B; C; D} a ruler and a pencil, you can contruct a fair approximation of the red spline by finding a number of points on the spline and then connecting them with straight segments. Here's how it works:

C

A

On the left you see a standard (cubic) Bezier curve. The curve begins at {A} and ends at {D}. The direction of the vectors {AB} and {DC} control the tangents at the end points.

1 3 2 3

2 3

Let us say we want to find the Point {P} which is one third of the way between {A} and {D}. Note that this is not a third of the distance along the spline, but a third of the parameter domain. A curve like this has a parameter domain from 0.0 to 1.0, regardless of its actual dimensions.

2 3 1 3

1 3

1 3

2 3 1 3

2 3

The first order of business is to find the coordinates on the control-polygon which are one third between all adjacent control points. We started with 4 control points, now we have three subdivision coordinates (on segments {AB}, {BC} and {CD}). We perform the same trick once more, now reducing the number of coordinates to 2. As you can see, the line connecting these two points already intersects with the spline. (This line segment incidentally describes the tangent of the spline at t = 1/3 ) One final iteration gets rid of the last line segment and we are left with point {P}, which is ON the spline, at parameter 1/3 .

P 1 3

72

2 3

The de Casteljau algorithm is an easy way to evaluate spline points and tangents. The math gets a lot more complicated from here on out, and although some of it is essential information (like knots and periodicy), we will not discuss NURBS evaluators.


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.
RhinoPython Primer by Pablo C. Herrera - Issuu