470 likes | 517 Views
ICS 415 Computer Graphics Hermite Splines. Dr. Muhammed Al-Mulhem March 1, 2009. Spline. A spline is a a flexible strip used to produce a smooth curve through a set of points. Representations of Curves. A curve can be represented using: A sequence of points.
E N D
ICS 415Computer GraphicsHermite Splines Dr. Muhammed Al-Mulhem March 1, 2009 Dr. Muhammed Al-Mulhem
Spline • A spline is a a flexible strip used to produce a smooth curve through a set of points. Dr. Muhammed Al-Mulhem
Representations of Curves • A curve can be represented using: • A sequence of points. • A piecewise polynomial functions. • A spline curve refers to any composite curve formed with polynomial sections. Dr. Muhammed Al-Mulhem
Specifying Curves • A spline curve is specified as follows: • Giving a set of coordinate positions, called control Points, which indicate the general shape of the curve. • These points are then fitted with piecewise polynomial functions in one of two ways: • Interpolation • Approximation Dr. Muhammed Al-Mulhem
Specifying Curves • Interpolation: • When polynomial sections are fitted so that all the control points are on the curve, the resulting curve is said to interpolate the set of control points. Dr. Muhammed Al-Mulhem
Specifying Curves • Approximation • When polynomial sections are fitted so that some or all the control points are not on the curve , the resulting curve is said to approximate the set of control points. Dr. Muhammed Al-Mulhem
Parametric Continuity • To ensure a smooth transition from one section of a piecewise parametric spline to the next, we impose various continuity conditions at the connection points. • If each section of a spline curve is described with a set of parametric coordinate function of the form x = x(u), y= y(u), z = z(u), u1 <= u <= u2 • We set parametric continuity by matching the parametric derivatives of adjoining curve sections at their common boundary. Dr. Muhammed Al-Mulhem
Parametric Continuity • Various continuity conditions: • C0 continuity (Zero-order parametric continuity): • Means simply that curves meet. That is, the values of x, y, and z evaluated at u2 for the first curve section are equal, respectively, to the values of x, y, and z evaluated at u1 of the next curve section. Dr. Muhammed Al-Mulhem
Parametric Continuity • C1 continuity (First-order parametric continuity): • Means that is the first parametric derivatives (tangent line) of the coordinate functions (above equations in slide 7) for two successive curve sections are equal at their joining point. Dr. Muhammed Al-Mulhem
Parametric Continuity • C2 continuity (Second-order parametric continuity): • Means that both the first and second parametric derivatives of the two curve sections are the same at the intersection. • Higher order parametric continuity conditions are defined similarly. Dr. Muhammed Al-Mulhem
Parametric Continuity Dr. Muhammed Al-Mulhem
Parametric Continuity Dr. Muhammed Al-Mulhem
Cubic Spline • Cubic spline requires less calculations and storage space, and more stable than higher-order polynomials. • Given a set of control points, cubic interpolation splines are obtained by fitting the input points with a piecewise cubic polynomial curve that passes through every control point. Dr. Muhammed Al-Mulhem
Cubic Polynomials • A parametric cubic polynomial that is to be fitted between each pair of control points with the following equations: x(t) = axt3 + bxt2 + cxt + dx y(t) = axt3 + bxt2 + cxt + dx z(t) = axt3 + bxt2 + cxt + dx 0 <= t <= 1 Dr. Muhammed Al-Mulhem
Cubic Polynomials • Let T = [t3 t2 t 1] • Coefficient Matrix C • The the cuve Q(t) can be represented as: • Q(t) = T*C Dr. Muhammed Al-Mulhem
Parametric Curves • How do we find the tangent to a curve? • If f(x) = x2 -4 • tangent at (x=3) is • f’(x) = 2x - 4 = 2(3) - 4 = 2 • Derivative of Q(t) is the tangent vector at t: Dr. Muhammed Al-Mulhem
Piecewise Curve Segments • One curve constructed by connecting many smaller segments end-to-end • Must have rules for how the segments are joined • Continuity describes the joint • Parametric continuity • Geometric continuity Dr. Muhammed Al-Mulhem
Parametric Continuity • C1 is tangent continuity (velocity) • C2 is 2nd derivative continuity (acceleration) • Matching direction and magnitude of dn / dtn • Cn continous Dr. Muhammed Al-Mulhem
Geometric Continuity • Requires the parametric dervatives of the two sections are prportional to each other at their common boundary, instead of requiring equality. • If positions match • G0 geometric continuity • If direction (but not necessarily magnitude) of tangent matches • G1 geometric continuity • The tangent value at the end of one curve is proportional to the tangent value of the beginning of the next curve Dr. Muhammed Al-Mulhem
Parametric Cubic Curves • In order to assure C2 continuity, curves must be of at least degree 3 • Here is the parametric definition of a cubic (degree 3) spline in two dimensions • How do we extend it to three dimensions? Dr. Muhammed Al-Mulhem
Parametric Cubic Splines • Can represent this as a matrix. Dr. Muhammed Al-Mulhem
Coefficients • So how do we select the coefficients? • The coefficients [ax bx cx dx] and [ay by cy dy] must satisfy the constraints defined by the continuity conditions Dr. Muhammed Al-Mulhem
Parametric Curves • There are many splines developed, some of these are: • Hermite • Bezier Dr. Muhammed Al-Mulhem
Hermite Splines • A Hermite spline is an interpolating cubic polynomial with a specified tangent at each control point. • It can be adjusted locally because each curve section is only dependent on its endpoint constraints. Dr. Muhammed Al-Mulhem
Hermite Cubic Splines • One cubic curve for each dimension. • A curve constrained to x/y-plane has two curves. Dr. Muhammed Al-Mulhem
Hermite Cubic Splines • A 2-D Hermite Cubic Spline is defined by eight parameters: a, b, c, d, e, f, g, h • How do we convert the intuitive endpoint constraints into these (relatively) unintuitive eight parameters? • We know: • (x, y) position at t = 0, p1 • (x, y) position at t = 1, p2 • (x, y) derivative at t = 0, dp/dt • (x, y) derivative at t = 1, dp/dt Dr. Muhammed Al-Mulhem
Hermite Cubic Spline • We know: • (x, y) position at t = 0, p1 Dr. Muhammed Al-Mulhem
Hermite Cubic Spline • We know: • (x, y) position at t = 1, p2 Dr. Muhammed Al-Mulhem
Hermite Cubic Splines • So far we have four equations, but we have eight unknowns • Use the derivatives Dr. Muhammed Al-Mulhem
Hermite Cubic Spline • We know: • (x, y) derivative at t = 0, dp/dt Dr. Muhammed Al-Mulhem
Hermite Cubic Spline • We know: • (x, y) derivative at t = 1, dp/dt Dr. Muhammed Al-Mulhem
Hermite Specification • Matrix equation for Hermite Curve t3 t2 t1 t0 t = 0 p1 t = 1 p2 t = 0 r p1 r p2 t = 1 Dr. Muhammed Al-Mulhem
Solve Hermite Matrix Dr. Muhammed Al-Mulhem
Spline and Geometry Matrices MHermite GHermite Dr. Muhammed Al-Mulhem
Resulting Hermite Spline Equation Dr. Muhammed Al-Mulhem
Sample Hermite Curves Dr. Muhammed Al-Mulhem
Hermite Curves • If P(u) represents a parametric cubic point functionfor the cuve section between control points Pk and Pk+1 as shown bellow: Pk • P(u) = (x(u), y(u), z(u)), where • x(u)=axu3 + bxu2 + cxu + dx • y(u)=ayu3 + byu2 + cyu + dy • z(u)=azu3 + bzu2 + czu + dz Pk+1 Dr. Muhammed Al-Mulhem
Hermite Curves • The boundary conditions that define this Hermite curve section are: • P(0) = Pk • P(1) = Pk+1 • P’(0) = DPk • P’(1) = DPk+1 • With DPk andDPk+1 specifying the values for the parametric derivatives at control points Pk and Pk+1 Dr. Muhammed Al-Mulhem
Hermite Curves • We can write the vector equivalent for the Hermit curve section as: • P(u) = a u3 + b u2 + cu + d 0<= u <= 1 • Where the x, y and z components of P(u) is x(u)=axu3 + bxu2 + cxu + dx y(u)=ayu3 + byu2 + cyu + dy z(u)=azu3 + bzu2 + czu + dz Dr. Muhammed Al-Mulhem
Hermite Curves • The matrix equivalent is • And the derivative of the point function is Dr. Muhammed Al-Mulhem
Hermite Curves • Substituting endpoint values 0 and 1 for parameter u into the above two equations, we can express the Hermite boundary conditions in the matrix form Dr. Muhammed Al-Mulhem
Hermite Curves • Solving this equation for the polynomial coefficients, we have • MH, the Hermite matrix, is the inverse of the boundary condition matrix. Dr. Muhammed Al-Mulhem
Hermite Curves • The above matrix can be written in terms of the boundary conditions as • This can be used to determine the expressions for the polynomial Herimte functions. Dr. Muhammed Al-Mulhem
Hermite Blending Functions • The above matrix can be used to determine the expressions for the polynomial Herimte functions, • Hk(u) for k=0,1,2,3 • This can be done by carrying out the matrix multiplications and collecting coefficient for the boundary conditions to obtain the polynomial form: • P(u) = Pk(2u3 - 3u2 + 1) + Pk+1(-2u3 + 3u2) + DPk(u3 -2u2 + u) + DPk+1(u3 u2) • = Pk H0(u) + Pk+1 H1(u) + DPk H2(u) + DPk+1 H3(u) Dr. Muhammed Al-Mulhem
Blending Functions Dr. Muhammed Al-Mulhem