Chapter 7
Surface Modeling

7.1  Introduction

In a school, we have learned analytic representation of plane, sphere, cone (a general case of cylinder), and torus. These primitive surfaces are widely used in CAD systems for the design of mechanical components. Because of the importance of these primitive surfaces, their representation and software implementation will be discussed in this chapter.

Although most mechanical parts can be modeled simply using planes, spheres, cones, and toruses, many other geometric entities such as telephone handsets, car and airplane bodies, and sculptures may not be represented by these primitive surfaces. In CAD systems, Bézier and B-spline surfaces are used as the standard in industry for representing free-form or sculptured surfaces. For this reason, Bézier and B-spline surfaces are sometimes called free-form surfaces. In this chapter, we shall extend our knowledge on Bézier and B-spline curves to surfaces. Although it is very involved in processing a surface in terms of data arrangement and computation, the fundamental mathematics on surfaces is directly derived from curves. If you have read through the previous chapter on curve modeling and completed all examples, you will find that the underlying mathematics on parametric surfaces is fairly straightforward. Virtually, you do not need any new algorithms to evaluate Bézier and B-spline surfaces.

Bézier and B-spline surfaces are used in computer graphics and CAD systems for either iterative design of geometric shapes or representation of prescribed surfaces. The latter usually involves interpolation and approximation techniques. For example, to represent a clay model of a car by B-spline surfaces we may collect a set of digitized data from the clay model, then fit these digitized data by B-spline surfaces using interpolation or least square approximation method. In this chapter, we cannot cover all surface construction methods used for geometric shape design. Instead, we shall restrict ourselves to a number of essential methods to construct ruled surfaces, surfaces of revolution, and swept surfaces and show you how to use these techniques for interactive design of surfaces.

7.2  Primitive surfaces

In a middle school, we learned that a plane may be represented analytically by
Ax+By+Cz+D = 0,
where A, B, and C are some constants in the real field. Also a sphere may be given by
(x-x0)2+(y-y0)2+(z-z0)2 = r2,
where (x0, y0, z0) are the center of the sphere and r the radius. These representations are not very useful in CAGD application since they are coordinate dependent. To avoid such shortcomings, the primitive surfaces are represented in a vector-valued parametric form. In what follows, we shall briefly discuss the vector-valued representation of plane, sphere, cone, and torus. We shall also show you how to create three applets that let you display a sphere, cone, and torus.

Plane: An infinite plane is uniquely defined by a point p on the plane and a unit normal e3 of the plane as shown in Figure 7.1.

Figure 7.1: A plane.

To represent a bounded (or a finite) plane, we need two additional unit vectors that furnish the coordinate system, known as the frame, so that we can represent the plane parametrically over some finite intervals. Let e1 and e2 be two unit vectors such that e1, e2, and e3 are mutually orthogonal. Then, a finite plane may be defined as

S(u,v) = p + ue1 + ve2,    u [umin, umax],    v [vmin, vmax].
In theory, we can choose an arbitrary e1 provided that e1·e3 = 0 (i.e., e1 is orthogonal to e3) and define e2 as e2 = e3×e1. For numerical stability, however, we suggest the following approach to choose e1:

Implementing the above algorithm in Java gives

lambda = Math.abs(e_3.x);
e_1.x = 1.0;
e_1.y = e_1.z = 0.0;
if (lambda > Math.abs(e_3.y))
{
   lambda = e_3.y;
   e_1.y = 1.0;
   e_1.x = 0.0;
}
if (lambda < Math.abs(e_3.z))
{
   lambda = e_3.z;
   e_1.z = 1.0;
   e_1.x = e_1.y = 0.0;
}
temp = Math.sqrt(1 - lambda * lambda);
e_1.x = (e_1.x - lambda * e_3.x) / temp;
e_1.y = (e_1.y - lambda * e_3.y) / temp;
e_1.z = (e_1.x - lambda * e_3.z) / temp;

The above algorithm will be used throughout this book to compute an orthogonal unit vector with respect to another unit vector e3 whenever there is a need.

We now compute the first order partial derivatives. Differentiating S(u,v) with respect to u and v gives:

S
u
= e1,    S
v
= e2.
Accordingly, the surface normal is given by
S
u
× S
v
= e1×e2 = e3.

Sphere: A sphere is uniquely defined by the center C and radius r of the sphere. In order to represent a sphere in a vector space, we usually require the specification of a unit vector e3 pointing from the center to the ``north pole'' (actually, an arbitrary point on the sphere) as shown in Figure 7.2.

Accordingly, we may construct two unit vectors e1 and e2 such that e1, e2, and e3 are mutually orthogonal and hence represent the sphere in the local frame (i.e., e1, e2, and e3) with origin coincides with the center of the sphere. Let the angle parameter u [0,p] be oriented from the south to the north pole and v [0,2p] be, by default, oriented in accordance with the right-hand rule with respect to the vector e3 (see Figure 7.2). Then, projecting an arbitrary point p onto the e3 axis and the e1-e2 plane gives -rcosu and rsinu respectively. If rsinu is further projected onto the e1 and e2 axes, we obtain respectively the coordinates on these two axes as rsinucosv and rsinusinv. Consequently, we can write p in the local coordinate system as

p = rsinucosve1 + rsinusinve2-rcosue3 = rsinu(cosve1+sinve2)-rcosue3.
Since p is an arbitrary point on the sphere, the above equation is the representation of the sphere in the local frame. The representation of a sphere with center at C is thus given by
S(u,v) = C + rsinu(cosve1+sinve2) - rcosue3.
Differentiating S(u,v) with respect to u and v gives the first order partial derivatives:
S
u
= rsinu(cosve1+sinve2)+rsinu,     S
v
= rsinu(-sinve1+cosve2).
Based on our discuss on a sphere, we now create the GSphere class that defines a sphere and provides some member methods for evaluation. The source code GSphere is listed as follows:

The above code is a direct implementation of the math equations discussed previous. Save the above code under the name GSphere.java in the directory GeomLib and compile it to get GSphere.class. Let us now create the applet ShowSphere to display a predefine sphere. The code is listed below.

Save the above code in Ch6 and compile it to get ShowSphere.class. We can then create a HTML file to invoke the applet.

Cone/Cylinder: A cone is defined by the base ellipse r(v) and the major half angle a [0,p/2) as shown in Figure 7.3.

Let u be the arc length parameter along the the direction of the normal of the base ellipse. Then, the scale factor for an ellipse at u to the base ellipse is

1 + u
a
tana,
where, a is the length of the major axis of the base ellipse. Accordingly, the cone is represented as
S(u,v) = C+

1 + u
a
tana

(r(v)-c) + lun,
where l = 1. If the u increase in the direction of the normal of the base ellipse, l = 1. Otherwise, l = -1.

Differentiating S(u,v) with respect to u and v gives the first order partial derivatives:

S
u
= 1
a
tana(r(v)-c)+lun,    S
v
= (1+ u
a
tana) r(v).
Based our discuss on cones, we now create the GCone class that defines a cone and provides some member methods for evaluation. The source code of GCone class is listed as follows:

The above code is a direct implementation of the math equations discussed previously. Let's save it in the directory GeomLib and compile it to get GCone.class. We design the applet ShowCone that allows you to display the predefined cone. You can also click the scroll bar on the applet to change the angle a so as to obtain different cones. The source code of the ShowCone is given below.

Save the code in the directory Ch6 and compile it to get ShowCone.class. Then, write a HTML file to invoke the applet.

Torus: A torus is generated by moving a minor (or outside) circle along a major (or inner circle) with the center of the minor circle on the major circle as shown in Figure 7.4.

We denote the center, radius, and unit normal of the major circle respectively by C, R, and e3. If this major circle is parametrized by v in radian, we assume that the flow direction of v agrees with the right-hand rule with respect to the normal e3. We also denote the radius and parameter of the minor circle by r and u. In order to represent the torus in a vector-valued parametric form, we choose two unit vectors e1 and e2 such that e1, e2, and e3 are mutually orthogonal. Accordingly, the three unit vector and the center of the major circle furnish the local frame.

For v = 0, an arbitrary point on the torus in the local frame is given by

p = (R+rcosu)e1+rsinue3.
If this point is rotated about the axis e3 by an angle v, the coordinate on e3 does not change. Accordingly, we have
p = (R+rcosu)(cosve1+sinve2)+ rsinue3.
Since p is an arbitrary point on the torus, the above equation is the representation of the torus in the local frame. The torus in the global coordinate system is thus represented by
S(u,v) = c+(R+rcosu)(cosve1+sinve2)+ rsinue3.
Differentiating S(u,v) with respect to u and v gives the first order partial derivatives:
S
u
= -rsinu(cosve1+sinve2)+rcosue3,    S
v
= (R+rcosu)(-sinve1+cosve2).
Based our discussion on torus, we now create the GTorus class that define a torus and provides the evaluation methods. The source code is given below.

The above code is a straightforward implementation of the math equations discussed previously. Save this code in the directory GeomLib and compile it to get GTorus.class. We then design the ShowTorus class that allows you to display a torus and change the radius of the major circle by clicking the scroll bar. The source code is listed as follows.

7.3  Mathematical background on Bézier Surface

If you have gone through the section of Mathematical background on Bézier curve, then you will find the underlying mathematics for a Bézier surface is fairly straightforward.

We start our discussion with a straight line. Representing the straight line by a Bézier curve of degree one (i.e., order 2) defined over v [0,1] gives

S(v) = p0 (1-v)+p1 v,
where, p0 and p1 are two end points on the line. Rather than considering p0 and p1 as fixed points, we may take them to be the locus of other two Bézier lines defined over u [0,1], i.e.,
p0(u) = p0,0(1-u)+p1,0u
and
p1(u) = p0,1(1-u)+p1,1u.
Replacing p0 and p1 in S(v) by p0(u) and p1(u), we obtain a Bézier plane defined by four control vertices p0,0, p1,0, p0,1 and p1,1 over the parametric domain [0,1]×[0,1], i.e.,
S(u,v) = (p0,0(1-u)+p1,0u)(1-v)+ (p0,1(1-u)+p1,1u)v.
The above constructive description about surface is applicable to a generic Bézier surface as well. Let a Bézier curve of degree m defined over v [0,1] be denoted by
S(v) = m

j = 0 
pj Bj,m(v),      (7-1)
where, Bi,m(v) are the Bernstein polynomials of degree m. Similarly, we may consider pj to be the locus of a Bézier curve of degree n defined over u [0,1], i.e.,
pj(u) = n

i = 0 
pi,j Bj,n(u),
where, Bi,n(u) are the Bernstein polynomials of degree n. Replacing pj in equation (7-1) by pj(u) defines a Bézier surface of degree n in u and m in v:
S(u,v) = m

j = 0 

n

i = 0 
pi,j Bi,n(u)
Bj,m(v).      (7-2)
The control vertices pi,j form the control polyhedron of a Bézier surface. It is readily derived from the above equation that:

We now consider the evaluation of Bézier surfaces. Mathematically speaking, we do not need a new algorithm to evaluate a point on a Bézier surface with respect to the given u and v parameters. We can use the bases evaluation method discussed in the section of Mathematical background on Bézier curve to compute the basis functions Bi,n(u) and Bj,m(v). Let BFunct_u[i] and BFunct_v[j] store Bi,n(u) and Bj,m(v) respectively. Then, the point on the Bézier surface is computed as follows:

   rx = ry = rz = 0.0;
   for (j=0; j<=m; j++)
   {
      for (i=0; i<=n; i++)
      {
         temp = BFunct_u[i] * BFunct_v[j];
         rx += x[j][i] * temp;
         ry += y[j][i] * temp;
         rz += z[j][i] * temp;
      }
   }
noting that x[j][i], y[i][j], and z[i][j] denote the Cartesian coordinates of pi,j.

It is also true that we do not need a new algorithm to subdivide a Bézier surface. For example, if we want to subdivide the surface given in (7-2) at u = 0.5, we simply call the SubdivideCurve() method discussed in the previous chapter to halve

n

i = 0 
pi,jBi,n(u),    j = 0,1,, m
which are Bézier curves in u. Denoting the control vertices of the left-halved and right-halved by pi,j1 and pi,j2 respectively, we can write (7-2) as

    S(u,v) = j = 0m(i = 0npi,j1 Bi,n(u)+ i = 0npi,j2 Bi,n(u))Bj,m(v)

             = j = 0m(i = 0npi,j1 Bi,n(u))Bj,m(v)+ j = 0m(i = 0npi,j2 Bi,n(u))Bj,m(v).

As it is seen, the surface is now subdivided into two.

Analogous to a rational Bézier curve, a rational Bézier surface is given by

S(u,v) =
m

j = 0 

n

i = 0 
wi,jpi,j Bi,n(u)
Bj,m(v)

m

j = 0 

n

i = 0 
wi,j Bi,n(u)
Bj,m(v)
,
where wi,j are again the weights. Evaluation and subdivision of a rational Bézier surface is the same as those for a polynomial Bézier surface provided it is represented in homogeneous coordinates.

We now move to the next section to design an applet that allows you to display and manipulate a Bézier surface.

7.4  Creating Bézier surface applet

We have learned the mathematics on Bézier surfaces. Therefore, it is time for us to put the math in action. In particular, we shall create an applet that allows you to display a predefined Bézier surface and manipulate the control vertices to redesign the shape of the surface.

Let us first implement the GBezierSurface class that defines a Bézier surface and provides member methods for data setting and geometric processing. Similar to the GBezierCurve class, an one-dimensional array is used in GBezierSurface class to store the control vertices of a Bézier surface as shown below:

poles[]={x00,x10,,xn0,,x0m,x1m,, xnm, y00,y10,,yn0,}

Therefore, there are (m+1)×(n+1) elements for each dimension. The source code of GBezierSurface is listed as follows.

As you may note, we did not implement a method to evaluate the Bézier basis functions. This is because the computation of basis functions for a surface is the same as that for a curve. Therefore, when there is a need to evaluate the Bézier basis functions, we can create a Bézier curve object to access its member method EvalBases() defined in the GBezierCurve class. Since this curve object does not hold any control vertices, we may consider it as a ``dummy'' object. Save the above code under the name GBezierSurface.java in the GeomLib directory and compile it to get GBezierSurface.class.

Let us now design an applet that allows you to display and manipulate a predefined Bézier surface with option to change the density of grids. We call this applet the ShowBezSurf and type the following code.

What we need to emphasize in the above code is the way to display the control polyhedron and the resulting surface. The polyhedron is shown by plotting the polygons first in u-direction, then in v direction. The surface is displayed by plotting a number of iso-v curves and then iso-u curves. Therefore, the surface is actually seen through iso-curves that form the grids (or meshes) on the surface. This is an inexpensive method to visualize the surface. Save the above code under the name ShowBezSurf.java in the directory Ch6 and compile it to get ShowBezSurf.class. Then, we write a HTML file to invoke the applet. If everything works fine, you should see an applet simialr to that in Figure 7.5.

In CAGD applications, we often encounter a case where the shape of a single Bézier surface is not rich enough to describe a complicated geometric object (e.g., a arc body). One solution to such a problem is to blend a number of Bézier surfaces together with some constraints. The surface that is made of several Bézier surfaces is called a composite Bézier surface. Although a composite Bézier surface can meet the requirement of describing a complicated geometric shape, it is often not preferred in applications since it usually requires more control vertices than a B-spline surface does. Therefore, let us move to the next section to study the mathematics on B-spline surfaces.

7.5  Mathematical background on B-spline Surface

In the previous chapter, we have seen that B-spline curves provide a very useful way of generating smooth curves from a small number of control vertices in comparison with a composite Bézier curve. Therefore, B-spline curves are widely used in industry for modeling free-form curves. B-spline surfaces are related to B-spline curves in the same way that Bézier surfaces are related to Bézier curves. If you have gone through the sections of Mathematical background on B-spline curve and Mathematical background on Bézier Surface, you will find the content of this section is fairly understandable.

Let a B-spline curve of order kv with q control points be given by

S(v) = q-1

j = 0 
dj Nj,kv(v),
where, dj are the control vertices that form the control polygon of a B-spline curve and Nj,kv(v) are the B-spline basis functions defined by the v knot vector. Rather than considering the control vertices dj to be stationary points, we may take them to be the locus of the following B-spline curve of order ku with p control points:
dj = dj(u) = p-1

i = 0 
di,jNi,ku(u),
where, Ni,ku(u) are the B-spline basis functions defined by the u knot vector. Replacing dj in S(v) by dj(u) defines a B-spline surface of the form:
S(u,v) = q-1

j = 0 

p-1

i = 0 
di,j Ni,ku(u)
Nj,kv(v).      (7-3)
The control vertices di,j form the so-called control polyhedron of a B-spline surface. It is readily derived from equation (7-3) that:

We now consider the evaluation of B-spline surfaces. Mathematically speaking, we do not need a new algorithm to evaluate a point on a B-spline surface. Assume that we want to evaluate a B-spline surface with respect to the parameters u [uju, uju+1) and v [vjv, vjv+1). We then use the basis evaluation method discussed in the section of Mathematical background on B-spline curve to compute the basis functions Ni,ku(u) and Nj,kv(v). Due to the local support property of B-splines, the non-vanishing basis functions are Nju-ku+1(u),, Nju(u) and Njv-kv+1(v),, Njv(v). Therefore, the point on the surface is given by

p = kv-1

j = 0 
ku-1

i = 0 
d ju-ku+1+i, jv-kv+1+j Nju-ku+1(u) Njv-kv+1(v).

It is also true that we do not need a new algorithm to insert a knot into the existing u and v knot vectors of a B-spline surface. Suppose that we want to insert a new knot, say [`u], into the u knot vector of the surface given in (7-3) such that there are m [`u] in the existing u knot vector. We then simply apply the same knot insertion algorithm discussed in the section of Mathematical background on B-spline curve to each B-spline curve

p-1

i = 0 
di,jNi,ku(u),     j = 0,1,, q-1.
In the next section, we shall create an applet that allows you to insert a knot into the existing u knot vector. By then, you will have a chance to study the implementation of the knot insertion technique in detail.

Analogous to a rational B-spline curve, a rational B-spline surface is given by

S(u,v) =
q-1

j = 0 

p-1

i = 0 
wi,jdi,j Ni,ku(u)
Nj,kv(v)

m

j = 0 

p-1

i = 0 
wi,j Ni,q-1(u)
Nj,kv(v)
,
where wi,j are again the weights. Rational B-spline surfaces are also known as the NURBS (Non-Uniform Rational B-Spline) surfaces. Evaluation and knot insertion of a rational B-spline surface is the same as those for a polynomial B-spline surface provided it is represented in homogeneous coordinates.

Enough for the math. Let us move to the next section to design two applets that allow you to display and manipulate B-spline surfaces.

7.6  Creating B-spline surface applet

In this section, we shall create two applets that allow you to display and manipulate B-spline surfaces. Before doing so, we first need to implement the GBsplineSurface that defines a B-spline surface and provides member methods for data setting and geometric processing. In order to make the GBsplineSurface flexible enough to deal with both polynomial and rational surfaces, we use an one-dimensional array to store the control vertices, i.e.,

poles[]={x0,0,x1,0,,xp-1,0,,x0,q-1, x1,q-1, , xp-1,q-1,  y0,0,y1,0,, yp-1,0, }

Therefore, there are p×q elements for each dimension. The actual source code of GBsplineSurface is listed below.

Similar to the way we implemented GBezierSurface, we also create ``dummy'' B-spline curve objects to access member methods defined in the GBsplineCurve class, which avoids duplication of the same code. The EvalPoint() and EvalIsoCurve() methods are simply the implementation of the method discussed in the previous section. Save this code under the name GBsplineSurface.java in the GeomLib directory and compile it to get GBsplineSurface.class.

We now create the first applet ShowBspSurf that displays a B-spline surface with option to choose the density of grids. It should be pointed out that the GBsplineSurface class can handle generic polynomial B-spline surfaces. For simplicity, however, the surface in ShowBspSurf applet is predefined. When you understand the implementation detail, you can either modify or create a new applet that allows you to generate a sophisticated B-spline surface. Let us type the following code.

Save the code under the name ShowBspSurf.java in the directory Ch6 and compile it to get ShowBspSurf.class. Then, we write a HTML web page to invoke the applet. If everything is okay, you should be able to see an applet similar to that in Figure 7.6.

The B-spline surfaces in the applets are created by specifying the control vertices that form the control polyhedrons of the surfaces. In subsequent sections, we shall show you some important surface construction methods that start by designing curves then extend them to generate ruled surfaces, surfaces of revolution, and swept surfaces.

7.7  Ruled surface

Given two curves r1(u) and r2(u), a ruled surface is generated by moving a straight line joining corresponding points on two curves. Mathematically, a ruled surface is a linear blending surface between two curves, i.e.,
S(u,v) = r1(u)+v[r2(u)-r1(u)]
where, v varies in [0,1]. The two curve r1(u) and r2(u) can be any form of parametric curves such as ellipse, circle, Bézier, or B-spline curves.

Differentiating S(u,v) with respect to u and v gives the first order partial derivatives:

S
u
= r1(u)+v(r2(u)-r1(u))   and    S
v
= r2(u)-r1(u).

In what follows, we shall design an applet that allows you to create different ruled surfaces by manipulating two B-spline curves r1(u) and r2(u). Let us first define the GRuledSurface class of which the source code is given below.

The GRuledSurface class has two member variables bspcv1 and bspcv2 that define the ruled surface. The member method UpdateCurve is used to update one of the base curves. The EvalPoint method evaluate a point on the surface with respect to the given u and v parameters. Finally, the EvalIsovCurve method computes a set of points with respect to given v. It is noted that we do not need a method to evaluate iso-u curves since they are straight lines. Save the above code under the name GRuledSurface.java in the directory GeomLib and compile it to get GRuledSurface.class.

We now design the applet ShowRuleSurf that has two buttons Design Curve and Create Surface. When you click on the Design Curve button, you can manipulate the predefined B-spline curves. When you are satisfied with the shapes of two curves, you then click the Create Surface to construct a ruled surface. The source code is given as follows.

We save the above code under the name ShowRuleSurf.java in the directory Ch6 and compile it to get ShowRuleSurf.class. Then, write a HTML web page ShowRuleSurf.html to invoke the applet which looks similar to Figure 7.7.

7.8  Surface of revolution

A surface of revolution is generated by rotating a curve r(u) about an axis defined by a point q on the axis and the direction vector e3. Therefore, for any given u, the locus of a surface of revolution is a circular arc in v. By default, the v parameter increases in the direction that follows the right-hand rule with respect to e3. To represent a surface of revolution parametrically, we need to define a local frame (or a local coordinate system). For the purpose of numerical stability, it is desirable to find a point p on the curve r(u) such that this point has the largest distance to the axis. Projecting this point onto the axis obtains a point s. Let
e1 = p-s
|| p-s ||
,    e2 = e3×e1.
Then, e1, e2, and e3 furnish the vector bases for our local coordinate system. It should be noted that, in practice, we want an inexpensive method to determine a point on the trace curve such that we can build a unit vector e2 from this point. One approach is to compute p = r(u) at u = 0.5. If the distance from p to the axis is greater than the distance tolerance, p is valid. Otherwise, we take u to be some other value until we obtain a valid p.

Let C(u) = r(u)-s. Then, the three coordinates of C(u) in the local frame are given by

E1(u) = C(u)·e1,    E2(u) = C(u)·e2,    E3(u) = C(u)·e3.
Therefore, the trace curve in the local coordinate system is given by
C(u) = E1(u)e1 + E2(u)e2 + E3(u)e3.
When C(u) is rotated about the axis e3 by an angle v, the coordinate on the e3 axis (i.e., E3(u)) is not affected. Furthermore, if C(u) is project onto the e2- e3 plane, the magnitude (or length) of the projected C(u) is irrespect to the rotation. Therefore, we can derive the representation of the surface of revolution as follows:

    S(u,v) = s + E1(u)(cosve1+ sinve2) + E2(u)(-sinve1+cosve2 ) + E3(u)e3

             = s+(E1(u)cosv-E2(u)sinv)e1 + (E1(u)sinv+E2(u)cosv)e2 + E3(u)e3

If we differentiate S(u,v) with respect to u and v, we then obtain the first order partial derivatives:

       [(S)/(u)] = (E1(u)cosv-E2(u) sinv )e1 +(E1(u)sinv + E2(u)cosv)e2 + E3(u)e3,

       [(S)/(v)] = -(E1(u)sinv+E2(u)cosv)e1+(E1(u)cosv -E2(u)sinv)e2,

where E1(u) = C(u)·e1 = r(u)·e1, E2(u) = r(u)·e2, and E3 (u) = r(u) ·e3.

Having understood the mathematics on a surface of revolution, we can now design the GRevolSurface class of which the code is given below:

A surface of revolution is defined by a profile curve and an axis which in turn is defined by a base point and the direction vector e3. Therefore, the GRevolSurface class has respectively three member variables bspcv, basePoint, and e_3. We also declare three additional member variables e_1, e_2 and sigma that represent e1, e2, and s. They are declared as private since there is no need for users to be involved with them. Similar to other geometric surfaces classes, we have some member methods that deal with updating and evaluating. Save the above code under the name GRevolSurface.java in GeomLib and compile it to get GRevolSurface.class.

Let's create the applet ShowRevSurf that allows us to generate and manipulate surfaces of revolution. The source code of ShowRevSurf is given below.

We save the above code under the name ShowRevSurf.java in the directory GeomLib and compile it to get ShowRevSurf.class. We then write a HTML web page named ShowRevSurf.html to invoke the applet. If verything works well, we should see an applet similar to that in Figure 7.8.

7.9  Swept surface

A swept surface is created by moving a given section curve C(v) along a prescribed curve (i.e., a trace or trajectory curve) r(u) with the origin of the section curve coinciding with the trace curve r(u). Let t(u), n(u), b(u) be three mutually orthogonal unit vectors associated with the trace curve r(u), then the swept surface is given by
S(u,v) = r(u)+[C(v)·t(u)]t(u)+[C(v)·n(u)]n(u)+[C(v)·b(u)]b(u).
If r(u) is a regular curve (i.e., the first derivative of r(u) dose not vanish), we may choose t(u), n(u), b(u) to be the Frenet frame. Accordingly, we have
t(u) = r(u)
||r||
,    n(u) = t(u)×k,     b(u) = n(u)×t(u),
where, ||r(u) || = {r (u)·r(u)}.