Download presentation
Presentation is loading. Please wait.
1
Introduction We have dealt with polylines and mesh shapes. We want a way to describe curved shapes which will make them easy to draw.
2
Example: Animation The path of the camera through the scene must be specified at each instant. The camera is located on the path P(t) at time t.
3
Animation (2) The designer chooses a suitable function P(t) so that the camera moves as desired, perhaps taking snapshot #1 at t = 0.1, snapshot #2 at t = 0.2, etc. The view direction of the camera must also be specified at each instant.
4
Animation (3) The camera must move smoothly along P(t) without any disturbing jerks. –This imposes conditions on the velocity P’(t). Other objects might move as well: the car, the boat, and any people coming out of the house. The movement of each of these objects must be described by specifying appropriate parametric functions F(t), G(t), etc.
5
Smoothness of Motion The velocity v(t) is a vector that describes the speed and direction of an object moving along P(t) as it traverses the curve. It is given by
6
Smoothness of Motion (2) The tangent line to the curve P(t) at t = t 0 (in parametric form) is L(u). It passes through P(t 0 ) at u = 0 and moves in the direction v(t 0 ). L(u) = P(t 0 ) + v(t 0 ) u
7
Smoothness of Motion (3) The normal direction to a curve may be found at each point. It is defined as the direction perpendicular to the tangent line at the point. If the tangent line has direction v(t 0 ) at time t 0, the normal direction at t 0 is any multiple of the vector –n(t 0 ) = v┴( t 0 ) = (-dy/dt, dx/dt)| t = t0
8
Example: Motion on an Ellipse The figure shows velocities along an ellipse. What happens if, at t = a, the speed increases by a factor of 3?
9
Motion along an Ellipse (2) The trajectory is an ellipse; at t = a both x(t) and y(t) start to oscillate 3 times faster. Their derivatives at t = a are discontinuous. The shape of the curve is the same, but the motion changes.
10
Parametric Continuity We say a curve P(t) has k-th order parametric continuity everywhere in the t- interval [a, b] if all derivatives of the curve, up through the k-th, exist and are continuous at all points inside [a, b]. Briefly, P( ) is k-smooth in [a, b]. We insist on at least 1-smooth curves for animation, to avoid jerky motion.
11
Visual Smoothness A curve in an interval is 0-smooth if it is continuous. A curve is 1-smooth if its first derivative exists and is continuous throughout the interval. A curve is 2-smooth if its first and second derivatives exist and are continuous throughout the interval. A curve is 3-smooth if its first, second, and third derivatives exist and are continuous throughout the interval. –A 3-smooth curve must also be 2-smooth, but a 2- smooth curve may or may not be 3-smooth.
12
Geometric Continuity (G k - continuity). G 0 continuity is the same as 0- smoothness: P(t) is continuous with respect to t throughout [a, b]. G 1 continuity in [a, b] means that P’(c-) = k P'(c+) for some constant k and for every c in the interval [a,b]. G 2 continuity in [a, b] means that P’(c-) = k P’(c+) and P’’(c-) = m P’’(c+) for constants k and m and for every c in the interval [a, b].
13
Describing Curves by Polynomials A k th degree polynomial is a function given by P (t) = a k t k + a k-1 t k-1 + … + a 1 t + a 0. {a k, a k-1, …, a 0 } are the coefficients. Degree of the polynomial: highest power of t in it (i.e., k). Order of the polynomial: number of coefficients (i.e., k+1).
14
Polynomials of Degree 1 P(t) = a 0 + a 1 t, a linear curve (straight line). –The equation for P(t) is (in 2 dimensions) 2 equations, one for x(t) and one for y(t). –In 3 dimensions, it is 3 equations, one each for x(t), y(t), z(t). –P(t) passes through point a 0 at t = 0, and through point a 1 at t = 1.
15
Polynomials of Degree 2 X(t) = at 2 + bt + c, y(t) = dt 2 + et + f –For any choice of a, b, c, d, e, and f, this curve is a parabola. –We cannot generate an ellipse or a hyperbola from this form. More generally, we use F(x, y) = Ax 2 + 2Bxy + Cy 2 + Dx + Ey +F = 0 to generate conic sections.
16
Polynomials of Degree 2 (cont.) Which conic is generated depends on the value of the discriminant, AC – B 2. –If AC – B 2 > 0, we generate an ellipse. –If AC – B 2 = 0, we generate a parabola. –If AC – B 2 < 0, we generate a hyperbola. Example implicit functions: –Ellipse: x 2 + xy + y 2 - 1: (AC-B 2 = 0.75) –Parabola: x 2 + 2xy + y 2 + 3x – 6y – 7: (AC-B 2 = 0) –Hyperbola: x 2 + 4xy + 2y 2 -4x +y -3: (AC-B 2 = -2)
17
Polynomials of Degree 2 (cont.) A special case of the general quadratic form, the common vertex equation, y 2 = 2px – (1-ε 2 )x 2, shows how the conic sections are related. –This curve passes through (0,0) and has a size proportional to constant p. The conic that it describes depends on the value of the eccentricity ε. –Eccentricity measures how far off the curve is from a perfect circle (eccentricity = 0).
18
Polynomials of Degree 2 (cont.)
19
Polynomial Curves of Degree 3 and Higher Polynomial curves of degree 3 and higher do not easily convert to a parametric form. Cubic polynomials prove very useful in curve and surface design, but start with a collection of control points provided by the designer, and use an algorithm to generate points on the curve. The designer may edit the positions of the control points and view the new curve. This approach is visual, allowing the designer to see the progress of the curve design as the process continues.
20
Rational Parametric Forms X and y are defined as the ratio of two polynomials (quadratic in the example). P 0, P 1, and P 2 are any 3 points on the plane, called control points. W is a weight parameter.
21
Rational Parametric Forms (2) The equation for P(t) is actually 2 equations: one each for x(t) and y(t). P(t) is a linear combination of control points. It turns out also to be an affine combination of these points, so it makes sense as a point.
22
Rational Parametric Forms (3) At t=0, the right hand side collapses simply to (x 0, y 0 ); this curve passes through, or interpolates, the point P 0. At t=1, it passes through P 2. For t in between 0 and 1, P(t) depends on all three points in a complicated way. The figure on the next slide shows the curves, which depend on the value of w.
23
Rational Parametric Forms (4)
24
Rational Parametric Forms (5) if w < 1 it is an ellipse if w = 1 it is a parabola if w > 1 it is a hyperbola Rational parametric forms provide a way to generate the conic sections parametrically.
25
Interactive Curve Design We wish to allow a designer to specify a small number of control points and draw a wide variety of curve shapes. The goal is to capture the shape of this curve in a form that permits it to be reproduced at will, adjusted in shape and size as desired, sent to a machine for automatic cutting or molding, etc. There is most likely no simple formula that matches it exactly.
26
Interactive Curve Design (2) To enter the curve, the designer moves the pointer along the curve (on a tablet) clicking at a set of control points P 0, P 1,... close to the curve.
27
Interactive Curve Design (3) The role of the algorithm is to produce a point P(t) for any value of t given to it. The data for the algorithm is the set of control points, which together determine the curve along which the points P(t) will fall.
28
Interactive Curve Design (4) The algorithm is usually implemented as a function Point2 curvePt(double t, RealPointArray pts) that returns a point for any value of t in a certain interval. To draw the curve the user can choose a sequence of t-values, evaluate curvePt() at each of them, and connect the points with line segments to form a polyline.
29
Interactive Curve Design (5) Steps in Interactive Curve Design: –1. Lay down the initial control points; –2. Use the algorithm to generate the curve; –3. If the curve is satisfactory, stop; –4. Else, move some control points; –5. Go to step 2;
30
Interpolation and Approximation Interpolation: curve passes through the control points (left). Approximation: curve passes near each control point (right).
31
Bezier Curves Bezier curves (approximating curves) were developed to assist in car shape design. The de Casteljau algorithm is used to draw them. The de Casteljau algorithm is based on a sequence of familiar tweening steps (Chapter 5) that are easy to implement. Because tweening is such a well-behaved procedure, it is possible to deduce many valuable properties of the curves that it generates.
32
Bezier Curves (2) Tweening 3 points to obtain a parabola: –Start with three points: P 0, P 1, and P 2. –Choose t between 0 and 1, say t = 0.3. –Locate the point A that is fraction t of the way along the line from P 0 to P 1. Similarly, locate B at fraction t between the endpoints P 1 and P 2 (using the same t). –The new points are A(t) = (1 - t)P 0 + tP 1, B(t) = (1 - t)P 1 + tP 2
33
Bezier Curves (3) Now repeat the linear interpolation step on these points (using the same t): Find the point, P(t), that lies fraction t of the way between A and B: P(t) = (1-t)A + tB.
34
Bezier Curves (4) If this process is carried out for every t between 0 and 1, the curve P(t) will be generated. The parametric form for this curve is P(t) = (1-t) 2 P 0 + 2t(1-t)P 1 + t 2 P 2
35
Bezier Curves (5) The parametric form for P(t) is quadratic in t, so we know the curve is a parabola. It will still be a parabola even if t is allowed to vary from –∞ to ∞. It passes through P 0 at t = 0 and through P 2 at t = 1 (why?) We thus have a well-defined process that can generate a smooth parabolic curve based on three given points.
36
Bezier Curves (6) The most common Bezier curves use 4 control points. For a given value of t, point A is placed fraction t of the way from P 0 to P 1, and similarly for points B and C. Then D is placed fraction t of the way from A to B, and similarly for point E. Finally, the desired point P is located fraction t of the way from D to E.
37
Bezier Curves (7) If this is done for every t between 0 and 1, the curve P(t) starts at P 0, is attracted toward P 1 and P 2, and ends at P 3. It is the Bezier curve determined by the four points.
38
Bezier Curves (8) The Bezier curve based on four points has the parametric form P(t) = P 0 (1-t) 3 + P 1 3(1- t) 2 t + P 2 3(1-t)t 2 + P 3 t 3. Each control point P i is weighted by a cubic polynomial, and the weighted terms are added. The terms involved here are known as Bernstein polynomials.
39
Bernstein Polynomials The Bernstein polynomials are These polynomials add to 1 for any value of t. [In fact, they are the expansion of (1 – t + t) 3.] Consequently, P(t) is an affine combination of points, and thus a legitimate point.
40
Bernstein Polynomials (2)
41
Blending Points with Bernstein Polynomials The points are vectors bound to the origin (e.g., P 0 = p o, etc.) and t = 0.3. Then p(0.3) = 0.343 p 0 + 0.441 p 1 + 0.189 p 2 + 0.027 p 3. In the figure the four vectors are weighted and the results are added using the parallelogram rule to form the vector p(0.3).
42
Generalizing Bezier Curves to Any Number of Points For each value of t, a succession of generations are built up, each by tweening adjacent points produced in the previous generation (superscript for P is the generation number): for i = 0,..., L.
43
Generalizing Bezier Curves to Any Number of Points (2) The resulting curve is For L ≥ k, the binomial coefficient is For L< k, the binomial coefficient is 0.
44
Properties of Bezier Curves Bezier curves have properties well-suited to CAD. –Endpoint Interpolation: The Bezier curve P(t) based on control points P 0, P 1,..., P L always interpolates P 0 and P L. –Affine Invariance: to apply an affine transformation T to all points P(t) on the Bezier curve, we transform the control points (once), and use the new control points to re-create the transformed Bezier curve Q(t) at any t. –
45
Properties of Bezier Curves (2) –Example: A Bezier curve based on four control points P 0,..., P 3. The points are rotated, scaled, and translated to the new control points Q k. –The Bezier curve for Q k is drawn. It is identical to the result of transforming the original Bezier curve.
46
Properties of Bezier Curves (3) –Convex Hull Property: a Bezier curve, P(t), never wanders outside its convex hull. –The convex hull of a set of points P 0, P 1,..., PL is the set of all convex combinations of the points; that is, the set of all points given by where each α k is non-negative, and they sum to 1.
47
Properties of Bezier Curves (4) Example: Even though the eight control points form a jagged control polygon, the designer knows the Bezier curve will flow smoothly between the two endpoints, never extending outside the convex hull.
48
Properties of Bezier Curves (5) Derivatives of Bezier Curves: the first derivative is where ΔP k = P k+1 - P k The velocity is another Bezier curve, built on a new set of control vectors ΔP k. Taking the derivative lowers the order of the curve by 1: the derivative of a cubic Bezier curve is a quadratic Bezier curve.
49
Drawing Bezier Curves Complete code for drawing Bezier curves is in Fig. 10.18.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.