Presentation on theme: "BEZIER CURVES Part II. Assume we are given two endpoints labelled E1 and E2 and two control points labelled C1 and C2. create a smooth curve whose endpoints."— Presentation transcript:
Assume we are given two endpoints labelled E1 and E2 and two control points labelled C1 and C2. create a smooth curve whose endpoints will be E1 and E2. The curve should have the additional property that the slope of the tangent line leaving E1 should be the same as the slope of the line connecting points E1 and C1.
In fact, the reason point C1 is called a control point is that the position of C1 relative to E1 determines the slope of the curve as it leaves point E1 and starts bending towards point E2. In general, the curve need not go through or even be near either C1 or C2. Similarly, we want our curve to finish by going through the endpoint E2, but as it does so, we want the shape of the curve to match the direction of the line segment connecting C2 to E2. Thus C2 acts as a control point, but its control over the shape of the curve is influenced primarily by C2 's position relative to the point E2. The control points C1 and C2 are independent of one another. It is only the relative positions of C1 and E1 and then that of C2 and E2 that will help determine the shape of the curve we would like to draw.
Homework Write a Matlab code to create a smooth curve whose endpoints will be E1 and E2. With the control points C1 and C2 variable!
We can imagine there could be many such ways to generate a curve like that shown earlier. In fact, we could simply draw the curve by using a freehand sketch, but there must be a simple way to do it using mathematics. Cubic polynomials turn out to fill the bill quite nicely; these polynomials are neither too simple to accomplish the task at hand, nor are they too complex to actually work with. trying to make use of two independent tangents at the curve endpoints A first attempt might be to try quadratic (2nd degree) polynomials, but these have only one non-constant derivative and we are trying to make use of two independent tangents at the curve endpoints. After some reflection we might think we could gain even more control by using 4th or 5th or even 6th degree polynomials, but while this is true, the resulting formulas become more complex and on a computer they take up more memory and more execution time. Cubic polynomials turn out to be sufficiently rich but not overly burdensome.
Given two endpoints E1(x1,y1) and E2(x2,y2) and given two control points C1(x3,y3) and C2(x4,y4), find the 8 cubic parametric coefficients a x, b x, c x, d x, a y, b y, c y, d y for the curve whose X and Y coordinates are parameterised by the cubic equations: in which t is the variable parameter. The domain for t may be assumed to be the closed interval [0,1]. We require the following four conditions hold:
Point M's coordinates can also be found after first computing five other midpoints. The points M1, and M2, and M3 are the midpoints of the three segments that were originally drawn and connecting the original four points E1, C1, and C2, and E2.
We can then draw the two segments which connect the three midpoints M1, M2, and M3. These two segments also have midpoints which we label as M4 and M5. The segment connecting M4 and M5 also has a midpoint and it is surprising that this point is the same M that is found when we let t = ½ in the above coordinate equations. To prove this for yourself all you need do is calculate all the midpoint coordinates, an easy exercise.