| |
|
|
||||
![]() |
||||||
| |
|
|||||
|
A Review of Bezier Surfaces The notation of a curve extends easily to represent a surface. From the general form of the Bezier curve in Eq. 1, a parametric surface is a function of two parameters, termed u and v, as shown in Eq. 5:
Since we have already established that we are interested only in cubic curves, we will only deal with cubic surfaces. A single Bezier surface is often called a patch, and Figure 2 shows a patch defined in two dimensions. Figure 2
Again, it is clear that the control points define the shape of the patch. 16 control points define this one. Equation 6 represents the patch, and you will notice that it is similar in form to the Bezier curves in Eq. 2.
The array of control points P is extended from four vectors to a 4x4 array of vectors. The easiest way to think of a parametric surface is to imagine using the array's four rows to draw four horizontal curves, and then the array's four columns to draw four vertical curves. Together, these curves will produce a mesh of quadrilaterals. Listing 2 shows code to evaluate the surface at any value of u and v in a similar manner to that in which Listing 1 would evaluate a curve: Listing 2 CVector3D CEvaluator::EvalSurface(PATCHCTRLPTS P, float u, float v) { assert (P != NULL); assert (u >= 0.0f && u <= 1.0f); assert (v >= 0.0f && v <= 1.0f); float BU[4], BV[4]; CVector3D Ret(0); BU[0] = (1.0f - u) * (1.0f - u) * (1.0f - u); BU[1] = 3.0f * u * (1 - u) * (1.0f - u); BU[2] = 3.0f * u * u * (1.0f - u); BU[3] = u * u * u; BV[0] = (1.0f - v) * (1.0f - v) * (1.0f - v); BV[1] = 3.0f * v * (1 - v) * (1.0f - v); BV[2] = 3.0f * v * v * (1.0f - v); BV[3] = v * v * v; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { Ret += P[i][j] * (BU[i] * BV[j]); } } return Ret; } |
|
|