Chapter 4 Curves
Chapter 4 Curves
CHAPTER 4
CURVES
4.1 Introduction
In order to understand the significance of curves, we should look into the types of model representations that are used in geometric modeling. Curves play a very significant role in CAD modeling, especially, for generating a wireframe model, which is the simplest form for representing a model. We can display an object on a monitor screen in three different computer-model forms: Wireframe model Surface Model Solid model Wireframe model: A wireframe model consist of points and curves only, and looks as if its made up with a bunch of wires. This is the simplest CAD model of an object. Advantages of this type of model include ease of creation and low level hardware and software requirements. Additionally, the data storage requirement is low. The main disadvantage of a wireframe model is that it can be very confusing to visualize. For example, a blind hole in a box may look like a solid cylinder, as shown in the figure.
4-1
Chapter 4 - Curves
In spite of its ambiguity, a wireframe model is still the most preferred form, because it can be created quickly and easily to verify a concept of an object. The wireframe model creation is somewhat similar to drawing a sketch by hand to communicate or conceptualize an object. As stated earlier, a wireframe model is created using points and curves only. Surface Model: sweeping a curve around or along an axis can create a surface model. The figures below show two instances of generating a surface model.
The appearance or resolution of a surface model depends on the number of sweeping instances we select. For a realistic looking model, we need to select a large number of instances, requiring a large computer memory, or, opt for a not-so realistic model by selecting a small number of instances, and save memory. In some commercial CAD packages we have the option of selecting the resolution of a model, other packages have a fixed value for resolution that cannot be changed by users. Surface models are useful for representing surfaces such as a soft-drink bottle, automobile fender, aircraft wing, and in general, any complicated curved surface. One of the limitations of a surface model is that there is no geometric definition of points that lie inside or outside the surface. Solid Model: Representation of an object by a solid model is relatively a new concept. There were only a couple of solids modeling CAD programs available in late 1980s, and they required mainframe computers to run on. However, in 1990s, due to the low cost and high speed, PCs have become the most popular solid modeling software platform, prompting almost all the CAD vendors to introduce their 3-D solid modeling software that will run on a PC. Solid models represent objects in a very realistic and unambiguous form; however, they require a large amount of storage memory and high-end computer hardware. A solid model can be shaded and rendered in desired colors to give it a more realist appearance.
4-2
Chapter 4 - Curves
4-3
Chapter 4 - Curves
This is an example of an explicit non-parametric curve form. In this equation, there is a unique single value of the dependent variable for each value of the independent variable. The implicit non-parametric form of an equation is, (x xc)2 + (y yc)2 = r2 Implicit non-parametric equation
In this equation, no distinction is made between the dependent and the independent variables. Parametric Equations: Parametric equations describe the dependent and independent variables in terms of a parameter. The equation can be converted to a non-parametric form, by eliminating the dependent and independent variables from the equation. Parametric equations allow great versatility in constructing space curves that are multi-valued and easily manipulated. Parametric curves can be defined in a constrained period (0 t 1); since curves are usually bounded in computer graphics, this characteristic is of considerable importance. Therefore, parametric form is the most common form of curve representation in geometric modeling. Examples of parametric and non-parametric equations follow. Non-Parametric Circle: x2 + y2 = r2 Parametric x = r cos, y = r sin
Where, is the parameter. CAD programs prefer a parametric equation for generating a curve. Parametric equations are converted into matrix equations to facilitate a computer solution, and then varying a parameter from 0 to 1 creates the points or curves. In this course, we will use the following parameters, with the range indicated, 0 t 1 0 s 1 0 2s 0 2s
4-4
Chapter 4 - Curves
. P (x, y)
P A A
4-5
Chapter 4 - Curves
The intersection of the plane PQ and the cone is a circle, where as, the intersection created by the plane AB is an ellipse. Other curves that can be created are parabola and hyperbola. Conic curves are used to create simple wireframe models of objects, which have edges that can be represented by these analytical curves. The fixed-form or analytical curves do not have inflection points, i.e., curves have slopes that are either positive or negative and do not change their sign (positive slope will remain positive and negative slope will remain negative). All conic curves can be represented by a quadratic equation, for example, circular and elliptical curves have quadratic polynomial equations.
(4.3)
This equation is converted into a matrix form so that a computer can solve it. We will now convert this equation into a matrix form. Let us assume that the plot starts at the point (xi, yi), and the center lies at the origin. We increment to ( +), giving us the new point on the circle (xi+1, yi+1), or xi+1 = r cos( +) yi+1 = r sin( +)
4-6
Chapter 4 - Curves
(xi+1, yi+1)
Expanding it by the use of trigonometric identities, we get: xi+1 = r cos cos - r sin sin yi+1 = r sin cos + r cos sin Substituting the values: xi = r cos, and yi = r sin, we get
(xi, yi)
xi+1 = xi cos - yi sin yi+1 = yi cos + xi sin In matrix form, these equations can be written as,
yi
1]
cos - sin 0 0
sin cos 0 0
0 0 1 0
0 0 0 1
(4.4)
Equation (4.4) is valid for a circle that has center at the origin. To find the equation of a circle that has center located at an arbitrary point (xc, yc), we can use the translation transformation. Note that the equation (4.4) can be interpreted as rotational transformation of points xi and yi about the origin. Now, instead of rotation about the origin, we wish to rotate the point about the fixed point (xc, yc). This can be accomplished by the three-step approach, discussed in chapter 2, i.e., first translate the fixed point to the origin, rotate the object, and finally translate it so that the fixed point is restored to its original position. Using this procedure we will get:
4-7
Chapter 4 - Curves
[xi+1
yi+1 0 [xi yi
(4.5)
Simplifying the equation we get, xi+1 = xc + (xi xc) cos - (yi yc) sin yi+1 = yc + (xi xc) sin + (yi yc) cos (4.6)
Even though, equations (4.6) can be used as an iterative formula to plot a circle or a circular curve, using the EXCEL or MATLAB, or any other plot routines, the matrix equation (4.5) is the preferred form for a CAD program. The original CAD programs used iterative formulas to generate curves. The BASIC and FORTRAN languages were used to write the CAD codes.
4-8
Chapter 4 - Curves
4.4.4 Ellipse
Following the procedure outlined in the previous section, we can derive the parametric equations of an ellipse. Parametric equation of an ellipse is given by the equation xi = a cos yi = b sin For a point on the ellipse, in general, the equation is xi+1 = xi cos (a/b) yi sin yi+1 = yi cos (b/a) xi sin 2a (4.7) 2b
For a more general case, when the axes of the ellipse are not parallel to the coordinate axes, and the center of the ellipse is at a distance xc, yc from the origin, the equation of the ellipse is given below. Let be the angle that the major axis makes with the horizontal (x-axis), as shown. The equation of the ellipse can be derived as xi = xc + xi cos yi sin yi = yc + xi sin + yi cos (4.8)
Where, x and y are the coordinate values of a Point on the ellipse, in term of the rotated axes x and y. Equations (4.8) can be used to write either as an iterative formula or as a matrix equation for creating an elliptical curve.
4-9
Chapter 4 - Curves
Now, we will discuss the higher order curves, which are represented by higher order polynomials. Lagrange polynomial is a popular polynomial function used for interpolation of high order polynomials.
When a sequence of planar points (x0, y0), (x1, y1), (x2, y2), .(xn, yn) is given, the nth degree of interpolated polynomial can be calculated by the Lagrange Polynomial equation, fn (x) = yi Li,n (x) where, Li,n (x) = [(x x0). (x xi-1) (x xi+1). (x xn)] / [(xi x0). (xi xi-1) (xi xi+1). (xi xn)] To understand the above expression better, note that The term (x xi) is skipped in the numerator, and The denominator starts with the term (xi x0) and skips the term (xi xi), which will make the expression equal to infinity. (4.10)
Example: Using the Lagrange polynomial, find the expression of the curve containing the points, P0(1, 1), P1(2, 2), P2(3, 1) Solution: Here, n = 2 and x0 =1, y0 = 1, x1 = 2, y1 = 2, etc. The polynomial is of a second degree. Expanding the Lagrange equation, we get, f2 (x) = y0 [(x - x1) (x - x2)] / [(x0 x1) (x0 x2)] + y1 [(x x0) (x - x2)] / [(x1 x0) (x1 x2)] + y2 [(x x0) (x x1)] / [(x2 x0) (x2 x1)]
4-10
Chapter 4 - Curves
= (1) [(x 2) (x 3)] / [(1 2) (1 3)] + (2) [(x-1) (x 3)] / [(2 1) (2 3)] + (1) [(x 1) (x - 2)] / [(3 1) (3- 2)] = (x2 5x + 6) 2 (x2 4 x + 3) + (x2 3 x + 2) or f2 (x) = - x2 + 4 x 2
This is the explicit non-parametric equation of a circle; the given points lie on the circumference.
A cubic polynomial is the lowest degree polynomial that can guarantee a C2 curve. Higher order polynomials are not used in CAD, because they tend to oscillate about the control points and require large data storage. Major CAD/CAM systems provide three types of synthetic curves: Hermite Cubic Spline, Bezier Curves, and B-Spline Curves.
ME 165 Lecture Notes by R. B. Agarwal Computer Aided Design in Mechanical Engineering
4-11
Chapter 4 - Curves
Cubic Spline curves pass through all the data points and therefore they can be called as interpolated curves. Bezier and B-Spline curves do not pass through all the data points, instead, they pass through the vicinity of these data points. Both the cubic spline and Bezier curve have first-order continuity, where as, B-Spline curves have a second-order continuity.
4-12
Chapter 4 - Curves
P(t) = a3 t3 + a2 t2 + a1 t + a0 If (x,y,z) are the coordinates of point P, the equation (4.12) can be written as, x(t) = a3x t3 + a2x t2 + a1x t + a0x y(t) = a3y t3 + a2y t2 + a1y t + a0y z(t) = a3z t3 + a2z t2 + a1z t + a0z
(4.12)
(4.13)
There are 12 unknown coefficients, aij, known as the algebraic coefficients. These coefficients can be evaluated by applying the boundary conditions at the end points. From the coordinates of the end points of each segment, six of the twelve needed equations are obtained. The other six equations are found by using the tangent vectors at the two ends of each segment. Substituting the boundary conditions at t = 0, and t = 1, we get, P(0) = a0, and P(1) = a3 + a2 + a1 + a0 (a) (b)
To find the tangent vectors, we differentiate equation (4.12), and get, P(t) = 3 a3 t2 + 2 a2 t + a1 Applying the boundary conditions at t = 0 and t = 1, we get, P(0) = a1 P(1) = 3 a3 + 2 a2 + a1 (c) (d)
Solving for the coefficients in terms of the P(t) and P(t) values in equations (a) through (d), we get, a0 = P(0) a1 = P(0) a2 = -3 P(0) +3 P(1) 2 P(0) P(1) a3 = 2 P(0) 2 P(1) + P(0) + P(1)
ME 165 Lecture Notes by R. B. Agarwal Computer Aided Design in Mechanical Engineering
(4.14)
4-13
Chapter 4 - Curves
The equation
P(t) = a3 t3 + a2 t2 + a1 t + a0
can be written, with coefficients aij replaced by the P(t) and P(t) values in equations (4.14), resulting, P(t) = [2 P(0) 2 P(1) + P(0) + P(1)] t3 + [-3 P(0) + 3 P(1) 2 P(0) P(1)] t2 + P(0) t + P(0) Or, rearranging the terms, we get, P(t) = [(2 t3 3 t2 + 1)] P(0) + [(-2 t3 + 3 t2)] P(1) + [(t3 2 t2 + t)] P(0) + [(t3 t2)] P(1) In matrix form the equation can be written as,
P(t) =
[t3
t2
1]
2 -2 1 1 -3 3 -2 -1 0 0 1 0 1 0 0 0
(4.15)
The equation in short form can be written as: P(t) = [t] [M]H [G] Where, the terms [t], [M]H, and [G] correspond to the terms on the right hand side of the equation (4.15). [M]H is called Hermite matrix of a cubic spline, and represents the constant matrix. The term [G] is called geometric coefficient matrix. Let us consider an example to understand how the equation (4.15) works. Example 5: A parametric cubic curve passes through the points (0,0), (2,4), (4,3), (5, -2) which are parametrized at t = 0, , , and 1, respectively. Determine the geometric coefficient matrix and the slope of the curve when t = 0.5. Solution: The points on the curve are (0,0) (2,4) at t = 0 at t =
Computer Aided Design in Mechanical Engineering
4-14
Chapter 4 - Curves
(4,3) (5,-2)
at t = at t = 1
0 2 4 5
0 4 3 -2
0 0.0156 0.4218 1
2 -2 1 1 -3 3 -2 -1 0 0 1 0 1 0 0 0
Solving, we get,
0 5 = 10.33 4.99
0 -2 22 -26
The slope at t = 0.5 is found by taking the first derivative of the equation (4.15), as follows, 2 -3 0 1 -2 1 1 3 -2 -1 0 1 0 0 0 0 0 0 5 -2 10.33 22 4.99 -26
0]
Note: coinciding the end points, and imposing equal values of the slopes, as shown, can create closed shape of a cubic spline.
4-15
Chapter 4 - Curves
Here, Vi represents the n+1 control points, and Bi,n (t) is the blending function for the Bezier representation and is given as n i
Bi,n (t) =
( ti ) (1-t)n-i
(4.17)
n i
n! = i! (n-i)! i = 0, 1, 2, .,n
4-16
Chapter 4 - Curves
The equations (4.18) force the curve to lie entirely within the convex figure (or envelop) set by the extreme points of the polygon formed by the control points. The envelope represents the figure created by stretching a rubber band around all the control points. The figure below shows that the first two points and the last two points form lines that are tangent to the curve. Also, as we move point v1, the curve changes shape, such that the tangent lines always remain tangent to the curve.
v2
v1
v1
v0
v3
Beziers blending function produces an nth degree polynomial for n+1 control points and forces the Bezier curve to interpolate the first and last control points. The intermediate control points pull the curve toward them, and can be used to adjust the curve to the desired shape.
4-17
Chapter 4 - Curves
t3 (1-t)0 = t3
By substituting the above values in the equation (4.19) we get P(t) = (1-t)3 V0 +3t (1-t)2 V1 + 3t2 (1-t) V2 + t3 V3 In matrix form this equation is written as -1 3 -3 1 3 -6 3 0 -3 3 0 0 1 0 0 0 V0 V1 V2 V3
P(t) = [t
1]
(4.20)
4-18
Chapter 4 - Curves
Point V3 is the middle point of the common points V2,, V3,, and V4 of curves A and B.
NOTE: Using the Bezier curves, we can create closed curves by making the first and last points of the control points coincide. Example: A cubic Bezier curve is described by the four control points: (0,0), (2,1), (5,2), (6,1). Find the tangent to the curve at t = 0.5. Solution: We will use the Bezier cubic polynomial, given in equation (4.20), which is,
P(t) = [t3
t2
1]
-1 3 -3 1
3 -6 3 0
-3 3 0 0
1 0 0 0
V0 V1 V2 V3
4-19
Chapter 4 - Curves
where, V0 = (0,0) V1 = (2,1) V2 = (5,2) V3 = (6,1) The tangent is given by the derivative of the general equation above,
P(t) = [3t
2t
0]
-1 3 -3 1
3 -6 3 0
-3 3 0 0
1 0 0 0
V0 V1 V2 V3
(4.21)
At t = 0.5, we get,
P(t) =
[3(.5)
2(.5) 1
0]
-1 3 -3 1
3 -6 3 0
-3 3 0 0
1 0 0 0
V0 V1 V2 V3
[6.75
1.5 0
1]
4-20
Chapter 4 - Curves
Pi(t) = 1/6[t3
t2
1]
-1 3 3 -6 -3 0 1 4
-3 3 3 1
1 0 0 0
(4.23)
4-21