Lập trình đồ họa trong C (phần 9) pot

50 406 0
Lập trình đồ họa trong C (phần 9) pot

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Section 10-9 B-Spline Curves and Surfaces (70-60) This matrix can be obtained by solving for the coefficients in a general cubic polynomial expression using the specified four boundary conditions. We can also modify the B-spline equations to include a tension parameter t (as in cardinal splines). The periodic, cubic B-spline with tension matrix then has the form which reduces to MB when t = 1. We obtain the periodic, cubic B-spline blending functions over the parame- ter range from 0 to 1 by expanding the matrix representation into polynomial form. For example, for the tension value t = 1, we have Open Uniform B-Splines This class of B-splines is a cross between uniform B-splines and nonuniform B- splines. Sometimes it is treated as a special type of uniform 8-spline, and some- times it is considered to be in the nonuniform B-spline classification. For the open uniform B-splines, or simply open B-splines, the knot spacing is uniform except at the ends where knot values are repeated d times. Following are two examples of open uniform, integer knot vectors, each with a starting value of 0: We can normalize these knot vectors to the unit interval from 0 to 1: 10,0,0.33,0.67,1, 1,); for o' = 2 and 11 = 3 l0,0,0,0,0.5,1,1,1,1t, ford=4andn=4 Chapter 10 Three-D~mensional Object Represemat~onr For any values of paranreters d and n, we can generate an open uniform knot vector with integer valucs using the calculations forOSj<d 1, fordsjSri (IO-(I ;) nd+2, forj>n for values of] ranging from 0 to n + d. With this assignment, the first d knots are assigned the value 0, and the last d knots have the value n - d + 2. Open uniform B-splines have characteristics that are very similar to Bezier splines. In fact, when d = tr + 1 (degree of the polynomial 1s n) open B-splines re- duce to Bezier splines, and all knot valucs are either O or 1. For example, with a cubic, open B-spline (d = 4) and four control points, the knot vector is The polynomial curve ior an open B-spline passes through the iirst and last con- trol points. Also, the slope of the parametric curves at the first control point is parallel to the line connecting the first two control points. And the parametric slope at the last control point is parallel to the line connecting the last two control points. So geometric constraints for matching curve sections are the same as for Kzier curves. As with Bbzier cuncs, specifying multiple control points at the same coor- dinate position pulls ans B-spline curve cioser to that position. Since open B- splines start at the first control point and end at the last specified control point, closed curves are generated by specifyng the first and last control points at the same position. Example 10-2 Open Uniform, Quadratic B-Splines From conditions 10-63 with 11 = 3 and ir = 1 (five control points), we obtain the following eight values for the knot vector: The total rangeof u is divided into seven subintervals, and each of the five blend- ing functions BkJ is defined over three subintervals, starting at knot position 11,. Thus, is defined from u, = 0 to 11, = 1, R,, is defined from u, = 0 to u4 = 2, and Big is defined from 14, = 2 to u7 = 3. Explicit polynomial expressions zre ob- tained for the blending functions from recurrence relations 10-55 as Figure 10-45 shows the shape of the these five blending functions. The local fea- tures of B-splines are again demonstrated. Blending function Bo,, is nonzero only in the subinterval from 0 to I, so the first control point influences the curve only in this interval. Similarly, function BdZ3 is zero outside the interval from 2 to 3, and the position of the last control point does not affect the shape 3f the begrnning and middle parts of the curve. Matrix formulations for open B-splines are not as conveniently generated as they are for periodic, uniform B-splines. This is due to the multiplicity of knot values at the beginning and end of the knot vector. For this class of splines, we can specify any values and intervals for the knot vec- tor. With nonuniform B-splines, we can choose multiple internal knot values and unequal spacing between the knot values. Some examples are Nonuniform B-splines provide increased flexibility in controlling a curve shape. With unequally spaced intervals in the knot vector, we obtain different shapes for the blending functions in different intervals, which can be used to ad- just spline shapes. By increasing knot multiplicity, we produce subtle variations in curve shape and even introduce discontinuities. Multiple knot values also re duce the continuity by 1 for each repeat of a particular value. We obtain the blending functions for a nonuniform B-spline using methods similar to those discussed for uniform and open B-splines. Given a set of n + I control points, we set the degree of the polynomial and select the knot values. Then, using the recurrence relations, we could either obtain the set of blending functions or evaluate curve positions directly for the display of the curve. Graph- ics packages often restrict the knot intervals to be either 0 or 1 to reduce compu- tations. A set of characteristic matrices then can be stored and used to compute Section 10-9 8-Splme Curves and Surfaces la) (bl id) Figzrrr 10-45 Opn, uniform 6-spline blending functions for n = 4 and d = 3 values along the spline curve without evaluatmg the recurrence relations for each curve point to be plotted. 6 Spline Surfaces Formulation of a B-spline surface is similar to that for B6zier splines. We can ob- tain a vector point function over a B-spline surface using the Cartesian product of B-spline blending functions in the form Section 10-10 - - Figure 10-46 A prototype helicopter, designed and modeled by Daniel Langlois of SOFTUIAGE, Inc., Montreal, using 180,000 Bspline surface patches. The scene was then rendered using ray tracing, bump mapping, and reflection mapping. (Coudesy silicon Graphics, Inc.) Beta-Splines whew the vector values for P~,,~, specify positions of the (n, + I) by (n2 + 1) con- trol points. B-spline surfaces exhibit the same properties as those of their component B- spline curves. A surface can be constructed from selected values for parameters d, and d, (which determine the polynomial degrees to be used) and from the specified knot vector. Figure 10-46 shows an object modeled with 8-spline sur- faces. 10-10 BETA-SPLINES A generalization of Bsplines are the beta-splines, also referred to as psplines, that are formulated by imposing geometric continuity conditions on the first and second ,parametic derivatives. The continuity parameters for beta-splines are called /3 parameters. Beta-Spline Continuity Conditions For a specified knot vector, we can designate the spline sections to the left and right of a particular knot ui with the position vectors P,-,(u) and PJu) (Fig. 10-47). Zero-order continuity (positional continuity), Go, at u, is obtained by requiring ~osition vectors along curve First-order continuity (unit tangent continuity), G1, is obtained by requiring sections to the left right tangent vectors to be proportional: of knot u,. 345 Chapter 10 DIP;- ~(u:) = P;(u,), PI > 0 (10-hb) Three-Dimensronal Objcc! Representaliom Here, parametric first derivatives are proportional, and the unit tangent vectors are continuous across the knot. Second-order continuity (cumture vector continuity), G2, is imposed with the condition where 6 can be assigned any real number, and pl > 0. The curvature vector pro- vides a measure of the amount of bending of the curve at position u,. When Pi = 1 and & = 0, beta-splines reduce to B-splines. Parameter is called the bins parameter since it controls the skewness of the curde. For PI > 1, the curve tends to flatten to the right in the direction of the unlt tangent vector at the knots. For 0 < p, < 1, the curve tends to flatten to the left. The effect of 0, on the shape of the spline curve is shown in Fig. 10-48. Parameter is called the tension parameter since it controls how tightly or loosely the spline fits the control graph. As /3, increases, the curve approaches the shape of the control graph, as shown in Fig. 10-49. Cubic, Period~c Beta-Spline Matrix Representation Applying the beta-spline boundary conditions to a cubic polynomial with a uni- form knot vector, we obtain the tollowing matrix representation for a periodic beta-spline: - Fiprt 10-48 Effect of parameter /3, on the shape of a beta-spline curve. . - Figrrrr 10-49 Effect of parameter & on the shape of a beta-spline curve. -2& 2(P2 + P: + P: + PJ -2(P2 + P: + PI + 1) Section 10-1 1 3(& + 2P:) Rational Splmes 6(P? - P:) 681 where S = p2 + 2fi: + 4lj: + 401 + 2. We obtain the B-spline matrix M, when /3, = 1 and = 0. And we get the 8-spline with tension matrix MB,when 10-1 1 RATIONAL SPLINES A rational function is simply the ratio of two polynomials. Thus, a rational spline is the ratio of two spline functions. For example a rational B-spline curve can be described with the position vector: where the pk are a set of n + 1 control-point positions. Parameters q are weight factors for the control points. The greater the value of a particular o,, the closer the curve 1s pulled toward the control point pk weighted by that parameter. When all weight factors are set to the value 1, we have the standard 8-spline curve since the denominator in Eq. 10-69 is 1 (the sum of the blending functions). Rational splines have two important advantages compared to nonrational splines. First, they provide an exact representation for quadric curves (conics), such as circles and ellipses. Nonrational splines, which are polynomials, can only approximate conics. This allows graphics packages to model all curve shapes with one representation-rational splines-without needing a library of curve functions to handle different design shapes. Another advantage of rational splines is that they are invariant with respect to a perspective viewing transfor- mation (Section 12-3). This means that we can apply a perspective viewing trans- formation to the control points of the rational curve, and we will obtain the cor- rect view of the curve. Nonrational splines, on the other hand, are not invariant with respect to a perspective viewing transformation. Typically, graphics design packages usc nonuniform knot-vector representations for constructing rational B- splines. These splines are referred to as NURBs (nonuniform rational B-splines). Homogeneous coordinate representations are used for rational splines, since the denominator can be treated as the homogeneous factor in a four-dimen- sional representation of the control points. Thus, a rational spline can be thought of as the projection of a four-dimensional nonrational spline into three-dimen- sional space. Constructing a rational 8-spline representation is carried out with the same procedures for constructing a nonrational representation. Given the set of control points, the degree of the polynomial, the weighting factors, and the knot vector, we apply the recurrence relations to obtain the blending functions. - Chapter 10 To plot conic sections with NURBs, we use a quadratic spline function (d = Three-Dlmensional Object 3) and three control points. We can do this with a B-spline function defined with Representat~ons the open knot vector: which is the same as a quadratic Bezier spline. We then set the weighting func- tions to the following values: and the rational B-spline representation is We then obtain the various conics (Fig. 10-50) with the following values for para- meter r: r > 1/2, w, > 1 (hyperbola section) r = 1 /2, o, = 1 (parabola section) r < 1 /2, o, < 1 (ellipse section) r = 0, w, = 0 (straight-line segment) We can generate a one-quarter arc of a unit circle in the first quadrant of the xy plane (Fig. 10-51) by setting w, = cosdand by choosing the control pints as Figure 70-50 Conic sections generated with various values of the r.1tional-spline wei5hting factor w,. I p2= (1, O) of the xy plane. Other sections of a unit circle can be obtained with different control-point posi- tions. A complete circle can be generated using geometric transformation in the xy plane. For example, we can reflect the one-quarter circular arc about the x and y axes to produce the circular arcs in the other three quadrants. In some CAD systems, we construct a conic section by specifying three points on an arc. A rational homogeneous-coordinate spline representation is then determined by computing control-point positions that wouId generate the selected conic type. As an example, a homogeneous representation for a unit cir- cular arc in the first quadran I[ of the xy plane-is 10-1 2 CONVERSION BETWEEN SPLINE REPRESENTATIONS Sometimes it is desirable to be able to switch from one spline representation 10 another. For instance, a Bezier representation is the most convenient one for sub- dividing a spline curve, while a B-spline representation offers greater design flex- ibility. So we might design a curve using B-spline sections, then we can convert to an equivalent Bezier representation to display the object using a recursive sub- d~vision procedure to locate coordinate positions along the curve. Suppose we have a spline description of an object that can be expressed with the following matrix product: where M,,l,,el is the matrix characterizing the spline representation, and M,,,, 1s the column matrix of geometric constraints (for example, control-point coordi- nates). To transform to a second representation with spline matrix MrpllnrZ, we need to determme the geometric constraint matrix Mgwm2 that produces the same vector point function for the object. That is, Three-D~mens~onal Object Or Representations Solving for MRPOm2, we have and the required transformation matrix that converts from the first spline repre- sentation to the second is then calculated as A nonuniform B-spline cannot be characterized ivith a general splme ma- trix. But we can rearrange the knot 5equence to change the nonuniform B-spline to a Bezier representation. Then the Bezier matrix could be converted to any other form. The following example calculates the transformation matrix tor conversion from a periodic, cubic B-spline representation to a cub~c, Bezier spline representa- tion. And the the hansformaticm matrix for converting from a cubic Bezier representa- tion to a periodic, cubic B-spline representation is [...]... object shapes are reprewllled with octrees, we can implement the set operations in CSG procedures by scanning the tree structure describing the contents of spatial octants This procedure, described in the following section, searches the octants and suboctants of a unit cube to locate the regions occupied by the two objects that are to be combined 10-16 OCTREES Hierarchical tree structures, called octrees,... modeling coordinates, where the surface-intersection calculations are carried out for the individual primitives Then surface intersections for the two objects are sorted and used to determine the composite object limits according to the specified set operation This procedure is Apeated for each pair of objects that are to be combined in the CSG tree for a particular object Once a CSG object has been... indicates a fairly fragmented surface Another way to create selfsimilar fractal objects is to punch holes in a given initiator, instead of adding more surface area Fig 10-75 shows some examples of fractal objects created in this way Geometric Construction of Statistically Self-Similar Fractals One way we can introduce some randomness into the geometric construction of a self-similar fractal is to choose... object to generate another In general, we can specify sweep constructions using any path For rotational sweeps, we can move along a circular path through any angular disfance from 0 to 360' For noncircular paths, we can specify the curve function describing the path and the distance of travel along the path In addition, we can vary the shape or size of the cross section along the sweep path Or we could... obtain statistically self-afine fractals Terrain, water, and clouds are typically n d e l e c l u.ith statistically self-affine fractal construction methods Invariant fractal sets are formed with nonlinear transformations This class of fractals includes selj-squaring fractals, such as the Mandelhrot set, which are formed with squaring functions in complex space; and sclf-irrverse fractals, formed with... related to the fractal dimension D of the object For statistically self-similar objects with a single scaling factors, we can cover the object with squares or cubes We then count the number u of covering boxes and use Eq 10-101 to estimate the fractal dimension For self-affine objects, we cover the object with rectangular boxes, since different directions are scaled differently In this case, the number... such as circles and rectangles, can be provided for sweep representations as menu options Other methods for obtaining two-dimensional figures include closed splinecurve constructions and cross-sectionalslices of solid objects Figure 10-53 illustrates a translational sweep The periodic spline curve in Fig 10-53(a) defines the object cross section We then perform a translational Figurr 10-53 Constructing... structured to accept definitions of objects in any form, such as a polygon mesh, curved surface patches, or solidgeometry constructions Using the minimum and maximum coordinate values of the object, we can define a box (parallelepiped) around the object This region of three-dimensional space containing the object is then tested, octant by octant, to generate the o&ee representation Once an octree representation... Three-dimensonal octree rotations are accomplished by applying the transformations to the occupied octants Visible-surface identification is carried out by searching the octants from front to back The first object detected is visible, so that info-mation can be transferred to a quadtree representation for display 10-17 BSP TREES This representation scheme is similar to octree encoding, except we now divide space... 10-74 Scaling the tetrahedron in (a) by a factor of 1/2 and positioning the scaled version on one face o the original tetrahedron produces the f b fractal surface ( ) object on each of the original four surfaces of the tetrahedron Each face of the original tetrahedron is converted to 6 smaller faces and the original face area is increased by a factor of 3/2 The fractal dimension of this surface is which . searches the octants and suboctants of a unit cube to locate the regions occupied by the two objects that are to be combined. 10-16 OCTREES Hierarchical tree structures, called octrees,. brute-force calcu- lation of each term in succession, is Horner's rule, which performs the calculations by successive factoring. This requires one multiplication and one addition at each step limits according to the specified set operation. This procedure is Apeated for each pair of objects that are to be combined in the CSG tree for a particular object. Once a CSG object has

Ngày đăng: 07/07/2014, 05:20

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan