130 likes | 297 Views
Beziers and Other Splines Petzold – Chapter 13. Jim Fawcett CSE778 – Advanced Windows Programming. Definitions. Spline: A curve defined by formula used to represent a segment of some complex figure. Bezier Spline:
E N D
Beziers and Other SplinesPetzold – Chapter 13 Jim Fawcett CSE778 – Advanced Windows Programming
Definitions • Spline: • A curve defined by formula used to represent a segment of some complex figure. • Bezier Spline: • A Cubic polynomial defined by four points. Each end of the Bezier passes through one of the points and is tangent to the line between that point and one of the others.
http://www.moshplant.com/direct-or/bezier/ second control point. first control point. first end point. second end point.
The Math • Parametric Form:x(t) = (1-t)3x0+3t(1-t)2x1+3t2(1-t)x2+t3x3y(t) = (1-t)3y0+3t(1-t)2y1+3t2(1-t)y2+t3y3where: • (x,y) are coordinates of a point • t is a distance along the curve with 0 < t < 1
Drawing Beziers • System.Drawing.Graphics • DrawBezier(Pen,Point,Point,Point,Point) • DrawBezier(Pen,Pointf,Pointf,Pointf,Pointf) • DrawBezier(Pen,Point[]) • DrawBezier(Pen,Pointf[])
Some Examples • Bezier Manual • Bezier Clock
Colinear Beziers • So how do we effectively connect several Bezier splines to make a more complex line? • To join smoothly, the slopes must match at boundry points. • To do that make the following three points colinear: • Second control point of the first Bezier • The end of the first Bezier (same as the begininng of the second Bezier) • The first control point of the second Bezier
Joining Beziers • Infinity Symbol • To Draw N Bezier Curves the number of points in the array must be 3N+1: DrawBezier(Pen, Point[])
Canonical Splines • A canonical spline passes through all points that define it. • The curve between adjacent points is called a segment. • Each internal segment is affected by the points at its ends and the next two enclosing points. • The shape of the segment is also controlled by its tension, usually between 0 and 1 that controls how “curvey” the segment appears.
Visualizing the Canonical Spline • System.Drawing.Graphics • DrawCurve(Pen, Point[]) • DrawCurve(Pen, PointF[]) • DrawCurve(Pen, Point[], float) • DrawCurve(Pen, Pointf[], float) • Canonical Spline Tension
Filling Closed Curves • System.Drawing.Graphics • DrawClosedCurve(Pen, Point[]) • DrawClosedCurve(Pen, PointF[]) • DrawClosedCurve(Pen, Point[], float, FillMode) • DrawClosedCurve(Pen, PointF[], float, FillMode) • FillMode: Alternate, Winding • Closed Curve Fill • See page 645 for the Math. Tension