Results 1 to 14 of 14

Thread: Parametric Cubic Spline Tutorial

Threaded View

  1. #1

    Thread Starter
    Fanatic Member VBAhack's Avatar
    Join Date
    Dec 2004
    Location
    Sector 000
    Posts
    617

    Parametric Cubic Spline Tutorial

    Parametric equations are powerful and flexible. Perhaps the most familiar example is the equation of a circle in the form x = r*cos(θ), y = r*sin(θ). In this case, the parameter θ is the independent variable and increases monotonically (i.e. each successive value is larger than the previous one, which is a requirement of parametric equations in general), and x and y are dependent variables. The resulting plot of y vs x can wrap on itself, which a circle indeed does. There are many forms of polynomial parametric equations (e.g. Bezier, B-Spline, NURBS, Catmull-Rom) that have entire books devoted to their understanding and use. In this tutorial, we offer a brief introduction by way of examples to provide a basic understanding of the relative simplicity of parametric equations. Specifically, we will build upon the tools learned in the cubic spline tutorial (http://www.vbforums.com/showthread.php?t=480806) to extend our knowledge to parametric cubic splines.

    Recall that a cubic spline is nothing more than a sequence of 3rd order polynomials joined at the endpoints with enforced 1st and 2nd derivative compatibility at interior points and specified end conditions at the free ends. Extending this concept to parametric splines just means formulating two sets of equations instead of one using the exact same methodology as a standard (non parametric) cubic spline. In the case of parametric cubic splines, each spline segment is represented by 2 equations in an independent variable s:

    x = f1(s) = ax(s-s0)3 + bx(s-s0)2 + cx(s-s0) + dx
    y = f2(s) = ay(s-s0)3 + by(s-s0)2 + cy(s-s0) + dy

    where s0 represents the value of the independent variable s at the beginning of the segment. Though not required, it is convenient to have s vary from 0 to 1. To get an idea of how powerful these equations are, consider the following simple equations for x & y:

    x = 26s3 - 40s2 + 15s - 1
    y = -4s2 + 3s

    The resulting plot of y vs x (for s = 0 to 1) is truly amazing. It almost seems magical that a single cubic polynomial (well, two actually) can generate such a complicated shape. That’s the power of parametric equations.

    Example Problem #1 (Connecting Spline Segments)

    Let’s focus on joining several parametric cubic spline segments to form a shape. Consider the following 4 points x = [(1,0), (0,1), (-1,0), (0,-1)]. There are several ways the points can be connected to form a shape. We wish to connect them in a crossing fashion as illustrated in the picture.
    .
    Attached Images Attached Images  
    Last edited by VBAhack; Aug 10th, 2007 at 07:04 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width