## 4. Curves, Surfaces, Volumes, and Splines

• It is necessary to define shapes mathematically when they are used in a computer.

• When we have a basic shape we can use equations to describe the shape,

circle

sphere

oval

plane

line

conic

etc.

• When the shape is not common, splines enable curved surfaces to be defined easily, with good control of the shape

• The source of control points for the splines are experimental data or design parameters or artistic judgment, etc.

• A spline uses end points, and some internal control points to adjust the shape which could not be defined with known primitive geometries.

• Common spline types are,

Polynomial

B-Spline

Bezier Splines

Hermite Splines

Catmull-Ron

etc.

• A spline can be used as a face in a B-Rep (solid) model.

• Some splines allow variable tension, such as the Catmull-Ron, and some B-Splines. This allows a skin which is stretched, tightly, or loose.

• Mathematical functions for curves and surfaces may be explicit or parametric.

Explicit: The values are directly related Parametric: The curve is described by varying other numbers 4.1 Lines and Curves

• Lines and curves are typically fit to data points.

• Typical distinctions are,

Two points define,

###### line (straight)

Three points define,

###### a complex curve that fits at the ends

Four or more points define,

###### a complex curve (spline) fit exactly at the ends only

• A spline based curve is typically represented with a polynomial.

#### 4.1.1 Lines

• Lines are typically represented in a parametric form. As we vary a parameter we move along the line. (Note: typical parameter variables are s,t,u,v) • Note: lines can also be represented in explicit form, although this is not as useful for mathematical modeling. #### 4.1.2 Splines

• A spline curve can interpolate or approximate a curve, • A bumpy curve will require a more complicated function (a polynomial with more degrees of freedom).

4.1.2.1 - Cubic

• A cubic spline typically gives the best data fit. The example below is a parametric fit to four data points.  • Try the example below • As we deal with different splines, the coefficient matrix changes,

• some of the different spline types are,

Coombs

Bezier

B-spline

4.1.2.2 - Bezier Curves

• A Bezier curve is approximated. The two endpoints are clearly defined, but the two inside points determine the internal shape by setting slopes at the ends,

• the basic relationships are, • Consider the shape of these curves are fixed to go through the endpoints, but are only guided by the two internal points • Instead of the matrix form for representing splines, we can also use blending functions (the results are the same for a 4 point set). And, this allows us to generalize to a larger number of degrees of freedom. • When using blending functions we can easily use more than three points (n=3) to define the spline.

• Bezier curves are distinctive in that changing an endpoint or control point will change the shape of the entire curve.

4.1.2.3 - Ferguson/Hermite Curves

• These curves are defined by endpoints and slopes at the endpoints. Note: here we need to specify derivatives.

• the basic relationships are, • These curves are of the greatest use when the endpoints of the line, and the slopes at those points are of more interest than the internal shape of the curve.

4.1.2.4 - Catmull-Rom Curves

• These curves go through every point, but we have a tightness variable ‘c’.

• As the value of ‘c’ goes to zero, the connecting lines become straight.

• The basic form of the matrix is, 4.1.2.5 - B-Splines

• B-Splines are typically defined using blending functions, and they will often have more than four points in their definition.

• The basic form for the nonuniform B-Spline is shown below in the Cox-deBoor recursive function. • If the intervals are all equal we call this uniform. When the intervals are different lengths we call this nonuniform. A nonuniform curve can take on much more complicated shapes. • We can also weight the points to increase their effects on the final curve shape. This creates a rational spline. • Non-Rational Uniform B-Spline (NURBS) curves are popular in CAD systems as they are the most general form of the spline curves. They combine both the rational weighting of points, and non-uniform knot spacing.

• Find a point at 140 degrees for NURB curve that models a sine wave from 0 to 180 degrees.  #### 4.1.3 Advanced Splines

• We can sometimes double up (or more) points to increase the effect of a weighting. This is more valuable when the function is not rational. If we do this in the middle of a curve it tends to pull the curve tight. When done at the ends it makes the ends more regular. • Quite often we will attach two spline segments in series. The connection between the segments will be said to have continuity. A zero order continuity means they touch, 1st order means they are smooth, etc. It is easier to ensure continuity with splines such as the Ferguson.

• A closed spline curve fully connects back to itself. (i.e., forms a loop)

4.2 Surface Patches

• Surfaces are typically defined with a variety of techniques. These include,

fixed primitives

swept surfaces

rotated surfaces

splines/free form

#### 4.2.1 Fixed Primitives

• These are basic geometric shapes defined either explicitly, or parametrically. These often include,

spheres

cylinders

cones/conics

ellipsoids

toroids

squares/rectangles

wedges

planes

• Normal analytical geometry is used for these shapes.

#### 4.2.2 Swept Surfaces

• Basically we start with a line in space, and sweep it through space to define a surface.

• A swept surface is normally represented parametrically, • The displacement vector T could also be a curved line. When the line is straight we often call the surface extruded.

#### 4.2.3 Rotated Surfaces

• This approach is much like the swept, except there is a central axis that we rotate about.

• Basically to rotate a section we define an axis of rotation, and rotate the line profile. #### 4.2.4 Free Form Splined Surfaces

• Basically, we can look at a splined surface as composed of normal spline curves. • Procedure for using splines in 3D,

1. Take a surface divided over an area, and break it into regions. 2. For each region find points needed for the spline. Here there are 16 shown in a 4 by 4 grid.

3. Use the measured x,y,z-points to calculate spline parameters in the u direction for each line of points, and then in the v direction.

4. To find new z-points use (x, y) to find the appropriate patch. Convert (x, y) to (u, v). Substitute (u, v) into splines to find estimated z-value. The calculation shown below uses the blending functions. • Surface normals can be calculated using partial derivatives. (Note: these are very important for many functions, such as rendering) 4.3 References

4.1 Chang, T-C., Wysk, R.A. and Wang, H-P., Computer-Aided Manufacturing, Second Edition, Prentice Hall, 1998.

4.2 Foley, J., Van Dam, A., “Fundamentals of Interactive Computer Graphics”, Addison Wesley, 1984.

4.3 Glassner, A.S., “An Introduction to Ray Tracing”, Academic Press, 1989.

4.4 Glassner, A.S., “Graphics Gems”, Academic Press, 1990.

4.5 Harrington, S., “Computer Graphics: A Programming Approach”, McGraw Hill, 1983.

4.6 Rogers, D.F., Adams, J.A., “Mathematical Elements for Computer Graphics”, McGraw Hill, 1990.

4.4 Problems

Problem 4.1 Use a Bezier spline to fit the four points below. If the curve is scaled from 0 to 1, find the point at 0.5 along the curve.   