Click here to load reader
Upload
lawrence
View
223
Download
0
Embed Size (px)
Citation preview
This article was downloaded by: [University Of Pittsburgh]On: 22 November 2014, At: 18:57Publisher: Taylor & FrancisInforma Ltd Registered in England and Wales Registered Number: 1072954 Registeredoffice: Mortimer House, 37-41 Mortimer Street, London W1T 3JH, UK
International Journal of MathematicalEducation in Science and TechnologyPublication details, including instructions for authors andsubscription information:http://www.tandfonline.com/loi/tmes20
Catmull-Rom curve fitting andinterpolation equationsLawrence Jerome a b ca Economics Department , Park University , Parkville, MO, USAb Department of General Education , Capella University ,Minneapolis, MN, USAc Department of General Education , Southern New HampshireUniversity , Manchester, NH, USAPublished online: 21 Jul 2010.
To cite this article: Lawrence Jerome (2010) Catmull-Rom curve fitting and interpolationequations, International Journal of Mathematical Education in Science and Technology, 41:6,842-849, DOI: 10.1080/0020739X.2010.486449
To link to this article: http://dx.doi.org/10.1080/0020739X.2010.486449
PLEASE SCROLL DOWN FOR ARTICLE
Taylor & Francis makes every effort to ensure the accuracy of all the information (the“Content”) contained in the publications on our platform. However, Taylor & Francis,our agents, and our licensors make no representations or warranties whatsoever as tothe accuracy, completeness, or suitability for any purpose of the Content. Any opinionsand views expressed in this publication are the opinions and views of the authors,and are not the views of or endorsed by Taylor & Francis. The accuracy of the Contentshould not be relied upon and should be independently verified with primary sourcesof information. Taylor and Francis shall not be liable for any losses, actions, claims,proceedings, demands, costs, expenses, damages, and other liabilities whatsoever orhowsoever caused arising directly or indirectly in connection with, in relation to or arisingout of the use of the Content.
This article may be used for research, teaching, and private study purposes. Anysubstantial or systematic reproduction, redistribution, reselling, loan, sub-licensing,systematic supply, or distribution in any form to anyone is expressly forbidden. Terms &
Conditions of access and use can be found at http://www.tandfonline.com/page/terms-and-conditions
Dow
nloa
ded
by [
Uni
vers
ity O
f Pi
ttsbu
rgh]
at 1
8:57
22
Nov
embe
r 20
14
[6] E. Wittmann, On the Preparation of Mathematics Teachers, The University of Georgia
Department of Mathematics Education Colloquium, Athens, GA, 1995.
[7] S. Abramovich and G. Brown, Integrating problem solving, technology, and the experience
of mathematical discovery in teacher education, J. Comput. Math. Sci. Teach. 15 (1996),
pp. 287–302.[8] C. Hoyles and R. Noss, A pedagogy for mathematical microworlds, Educ. Stud. Math. 23
(1992), pp. 31–57.[9] S. Abramovich, Inequalities and spreadsheet modeling, Spreadsheets Educ. 2 (2005),
pp. 1–22.
Catmull-Rom curve fitting and interpolation equations
Lawrence Jeromeabc*
aEconomics Department, Park University, Parkville, MO, USA; bDepartment of GeneralEducation, Capella University, Minneapolis, MN, USA; cDepartment of General
Education, Southern New Hampshire University, Manchester, NH, USA
(Received 4 December 2009)
Computer graphics and animation experts have been using the Catmull-Rom smooth curve interpolation equations since 1974, but the vector andmatrix equations can be derived and simplified using basic algebra,resulting in a simple set of linear equations with constant coefficients.A variety of uses of Catmull-Rom interpolation are demonstrated,including data point interpolation, image surround and key frameanimation.
Keywords: Catmull-Rom; spline; computer animation; simplified equations
Did you ever wonder how they create those great modern film animations? Would
you believe that algebra plays a key role in creating animations that appear so
life-like today? So, when students decry algebra and question, ‘Why are we studying
this stuff? We will never use it again in our lives!’, you can show them how algebra
plays a key role in creating the images so they enjoy!While equations provided by the graphics experts for creating animation seem to
be complex matrix and vector formulations, in fact they can be boiled down to
straightforward algebra and simple linear equations with constant coefficients that
any algebra student can use to create smooth curves and smooth animations.
Figure 1 shows an example of the sort of animation that can be done using simple
algebra. Figure 1 shows the progression from a complex shape in Frame 1 to the
straight line in Frame 5. Frames 2–4 were completely calculated using the
Catmull-Rom equations and coefficients outlined here.In film animation, beginning and ending Frames 1 and 5 are called ‘key frames’
and the interpolated images in Frames 2–4 are called ‘between frames’. Ever since
their publication in 1974, these and similar Catmull-Rom/Cardinal spline curve-
fitting equations have been used extensively by the computer graphics and film
industries for image editing, image enhancement and image creation between key
*Email: [email protected]
842 Classroom Notes
DOI: 10.1080/0020739X.2010.486449
Dow
nloa
ded
by [
Uni
vers
ity O
f Pi
ttsbu
rgh]
at 1
8:57
22
Nov
embe
r 20
14
frames [1]. For instance, Pixar used such key frame animation in ‘Toy Story’ and
‘A Bug’s Life’, demonstrating the power and efficacy of Catmull-Rom and other
Bezier spline techniques for interpolating between data points [2].However, these curve fitting techniques need not be the sole province of the
computer graphics field: the same equations can be applied to much more general
math and algebra problems, providing smooth curves between any set of points.
The Catmull-Rom equations are a subset of the more general Hermite curve
interpolation equations, and are also considered a subset of Cardinal splines and
Bezier splines [3]. These interpolation equations are used in well-known software
such as 3-D Studio Max (by Autodesk) and Lightwave (by Newtek). The
Catmull-Rom equations are particularly valuable because they create curves that
pass through all the points – and their shape can be controlled by a single ‘tension’
parameter (a fraction from 0 to 1), changing the interpolating curves from flat to well
curved (usually with tension¼½) to bulbous.The basic idea behind all these curve fitting techniques is to have a curve passing
through two points, with the shape of the curve controlled by the tangents to the
curves at those points. Since the curve passes through two points and uses two more
points to control the tangents, the curves are all cubic curves because it takes four
points to uniquely define a cubic curve. Figure 2 shows the basic setup for deriving
the Catmull-Rom/Cardinal spline equations.Note especially the t-axis in Figure 2, on the line connecting the two middle
points. The Catmull-Rom curve passes through points P2 and P3, and the points of
the curve Q(t) will be calculated for the value of t between 0 and 1. Since Q(t) is a
cubic function along the t axis, it has components along the x and y axes:
QxðtÞ ¼ axt3 þ bxt
2 þ cxtþ dx and QyðtÞ ¼ ayt3 þ byt
2 þ cytþ dy ð1Þ
Figure 1. Example of animation using Catmull-Rom interpolation between key frames.
International Journal of Mathematical Education in Science and Technology 843
Dow
nloa
ded
by [
Uni
vers
ity O
f Pi
ttsbu
rgh]
at 1
8:57
22
Nov
embe
r 20
14
Note that, although Q(t) only runs between the second and third points, all fourpoints contribute to the calculation of coefficients ax, bx, cx, dx and ay, by, cy, dy.Traditionally, the graphics experts state the constraint for deriving the Catmull-Romequations as ‘If we set each derivative to be one half of the vector between theprevious and next controls, we get a Catmull-Rom spline’ [4]. Thus, the tangent toQ(t) at P2 is ½ of the vector between P1 and P3, while the tangent of Q(t) at P3 is ½of the vector between P2 and P4. Figure 3 shows this relationship between tangentsand vectors.
The more general form of the Catmull-Rom curve uses a multiple between 0 and1 of the P1P3 vector, not just ½. This fraction is called the tension parameter, andallows the control of the curve from a flat straight line to bulbous curve, with the ½parameter creating a curve in between the two.
Deriving the general Catmull-Rom equations requires a little differential calculusand lots of algebra. But the end result is a very simple set of equations that produce anice series of curves through the points P2 and P3. Once the number of interpolationpoints between P2 and P3 is set, the calculations require only four coefficients ofthe four control points for each interpolation point – and those coefficients remainconstant for all curves anywhere on the plane. This is the beauty of the Catmull-Rominterpolation method: once the number of interpolation points is set and thecoefficients are calculated, the same coefficients can be used again to produce smoothinterpolation curves for any set of points.
Figure 2. Basic Catmull-Rom curve fitting setup.
Figure 3. Constraining Q(t) derivative to the fraction of P1P3 vector.
844 Classroom Notes
Dow
nloa
ded
by [
Uni
vers
ity O
f Pi
ttsbu
rgh]
at 1
8:57
22
Nov
embe
r 20
14
The following derivation uses the x and y components of vector-based
function, Q(t). Start with the x and y components of Q(t):
QxðtÞ ¼ axt3 þ bxt
2 þ cxtþ dx and QyðtÞ ¼ ayt3 þ byt
2 þ cytþ dy ð2Þ
The slope-vector constraint at P2 can be stated using differential calculus as
follows:
dQxðtÞ
dt¼ mTðx3 � x1Þ and
dQyðtÞ
dt¼ mTð y3 � y1Þ ð3Þ
Likewise, at P3, the slope-vector constraint will be
dQxðtÞ
dt¼ mTðx4 � x2Þ and
dQyðtÞ
dt¼ mTð y4 � y2Þ: ð4Þ
Now, the derivative of the cubic function Q(t) is
dQxðtÞ
dt¼ 3axt
2 þ 2bxtþ cx anddQyðtÞ
dt¼ 3ayt
2 þ 2bytþ cy: ð5Þ
Note that the x coordinate formulas are exactly the same as the y coordinate
formulas, so we only need to derive the Catmull-Rom equations for the x
coordinates and then at the end write the analogous formulas for the y coordinates.
We now have a total of four constraints:
(1) At P1, Qx(0)¼x2(2) At P2, Qx(1)¼x3(3) Derivative of Qx(t) at P1¼mT(x3� x1)(4) Derivative of Qx(t) at P2¼mT(x4� x2).
These four constraints lead to four simultaneous equations in the four unknown
coefficients:
dx ¼ x2 ð6Þ
ax þ bx þ cx þ dx ¼ x3 ð7Þ
cx ¼ mTðx3 � x1Þ ð8Þ
3ax þ 2bx þ cx ¼ mTðx4 � x2Þ: ð9Þ
Substituting Equations (6) and (8) into Equations (7) and (9) reduces the set to
two simultaneous equations in two unknowns:
ax þ bx ¼ x3 � x2 �mTðx3 � x1Þ ð10Þ
3ax þ 2bx ¼ mTðx4 � x2Þ �mTðx3 � x2Þ: ð11Þ
International Journal of Mathematical Education in Science and Technology 845
Dow
nloa
ded
by [
Uni
vers
ity O
f Pi
ttsbu
rgh]
at 1
8:57
22
Nov
embe
r 20
14
To solve the set of Equations (10) and (11), multiply (10) by 2 and subtract
from (11), then multiply (10) by 3 and subtract from (11):
ax ¼ mTðx4 � x2Þ þmTðx3 � x1Þ � 2ðx3 � x2Þ ð12Þ
bx ¼ mTðx4 � x2Þ � 2mTðx3 � x1Þ þ 3ðx3 � x2Þ: ð13Þ
Now, place the solutions for the cubic coefficients (Equations (6), (8), (12)
and (13)) into the original definition of Q(t), Equation (2), and collect terms for
x1, x2, x3 and x4:
QxðtÞ ¼ ½mTt3 þ 2mTt
2 �mTt�x1 þ ½ð2�mTÞt3 þ ðmT � 3Þt2 þ 1�x2
þ ½ðmT � 2Þt3 þ ð3� 2mTÞt2 þmTt�x3 þ ½mTt
3 �mTt2 �x4 ð14Þ
QyðtÞ ¼ ½�mTt3 þ 2mTt
2 �mTt� y1 þ ½ð2�mTÞt3 þ ðmT � 3Þt2 þ 1� y2
þ ½ðmT � 2Þt3 þ ð3� 2mTÞt2 þmTt� y3 þ ½mTt
3 �mTt2� y4: ð15Þ
Equations (14) and (15) then give the most general Catmull-Rom equations with
tension parameter, mT. Setting mT¼½ in (14) and (15) reduces the equations to
the usual form of Catmull-Rom used by computer graphics experts. While
Equations (14) and (15) look complicated, they can be greatly simplified by using
coefficients of x1, x2, x3 and x4:
QxðtÞ ¼ c1ðtÞx1 þ c2ðtÞx2 þ c3ðtÞx3 þ c4ðtÞx4 ð16Þ
QyðtÞ ¼ c1ðtÞ y1 þ c2ðtÞ y2 þ c3ðtÞ y3 þ c4ðtÞ y4 ð17Þ
where
c1ðtÞ ¼ ½�mTt3 þ 2mTt
2 �mTt�
c2ðtÞ ¼ ½ð2�mTÞt3 þ ðmT � 3Þt2 þ 1�
c3ðtÞ ¼ ½ðmT � 2Þt3 þ ð3� 2mTÞt2 þmTt�
c4ðtÞ ¼ ½mTt3 �mTt
2�
8>>>>>>>><>>>>>>>>:
ð18Þ
Equations (16) through (18) are the simple set of equations promised for
calculating smooth interpolation curves between any set of points. If the points do
not form a closed curve, start by using x1¼x2 and y1¼ y2 and end by using x3¼x4and y3¼ y4.
The crucial equations are the coefficients in Equation (18), which are equivalent
to Twigg’s ‘blending functions’ [5]. These coefficients for the Catmull-Rom
846 Classroom Notes
Dow
nloa
ded
by [
Uni
vers
ity O
f Pi
ttsbu
rgh]
at 1
8:57
22
Nov
embe
r 20
14
Figure 4. Catmull-Rom coefficients for four interpolation points and tension¼½.
Figure 5. Three different Catmull-Rom curves for different tension values.
International Journal of Mathematical Education in Science and Technology 847
Dow
nloa
ded
by [
Uni
vers
ity O
f Pi
ttsbu
rgh]
at 1
8:57
22
Nov
embe
r 20
14
equations (16) and (17) can be calculated separately for various values of tension andfor various numbers of interpolation points – but remain constant for all curves oncethose parameters are set. For instance, in Figure 4, tension, mT¼ 0.5 and there arefour interpolation points.
Figure 6. User selected points surrounding an image.
Figure 7. Catmull-Rom curve surrounding selected image.
848 Classroom Notes
Dow
nloa
ded
by [
Uni
vers
ity O
f Pi
ttsbu
rgh]
at 1
8:57
22
Nov
embe
r 20
14
Once the Catmull-Rom coefficients are calculated, they can be stored andassigned to arrays for extremely rapid calculations. Figure 5 compares the plotsof the three different Catmull-Rom curves created by changing the tensionparameter, mT, from mT¼ 0 to mT¼ 0.5 to mT¼ 1. The calculations for Figure 5used four interpolation points and the coefficients in Figure 4. The curvesbetween the first two points used the first point for x1 and x2, while the curvesbetween the last two points used the last points for x3 and x4. Note how mT¼ 0results in straight lines between points, whereas mT¼ 1 creates a more bulbouscurve and mT¼ 0.5 results in the usual Catmull-Rom smooth curve used in somany animation software.
This author was originally introduced to the Catmull-Rom interpolation curveswhile developing an image surround system for a film post production company.They wanted the user to be able to define some points around an image, then thesoftware will calculate the smooth curve around the image to isolate the image forediting, colourization, etc. Figure 6 shows a sample image with a number of pointsselected. Figure 7 shows the Catmull-Rom interpolated curve surrounding theselected image.
Conclusions: The Catmull-Rom equations provide a practical means ofgenerating smooth interpolation curves for a wide variety of data sets, as well assmooth between-frame animation. The simple set of Catmull-Rom equationsderived here can be used by anybody with modest programming skills. Theadjustable tension parameter allows the user to adjust the shape of calculatedcurves from straight and flat to round and bulbous. Whilst these equations havebeen used in the film and computer graphics industry for some years, theCatmull-Rom curve fitting equations can find wider application in mathematics,engineering and business.
References
[1] E. Catmull and R. Rom, A class of local interpolating splines, in Computer Aided Geometric
Design, R.E. Barnhill and R.F. Reisenfeld, eds., Academic Press, New York, 1974,pp. 317–326.
[2] Anonymous, Keyframe animation, Available at http://www-scf.usc.edu/�csci520/slides/keyframe.pdf
[3] N. Pipenbrunck, Hermite curve interpolation, Available at http://www.cubic.org/docs/
hermite.htm[4] Y.-Y. Chuang, Open GL and parametric curves, Advanced multimedia technology
computer graphics, 2005, slide 75.[5] C. Twigg, Catmull-Rom splines, 11 March 2003, Available at http://www.cs.cmu.edu/�462/
projects/assn2/assn2/catmullRom.pdf
International Journal of Mathematical Education in Science and Technology 849
Dow
nloa
ded
by [
Uni
vers
ity O
f Pi
ttsbu
rgh]
at 1
8:57
22
Nov
embe
r 20
14