Re: Scheper's Catmull-Rom curves, and Spiro curves

Hi, Dave-

Dave Crossland wrote (on 7/15/10 12:28 PM):
> On 14 July 2010 18:26, Doug Schepers<schepers@w3.org>  wrote:
>>   the section on
>>  interpolation masters (p. 158, Figures 10.9 and 10.10) was particularly
>>  interesting.  I think you and I talked about this in Brussels, and I wonder
>>  how well Catmull-Rom curves would perform in this regard?
>
> IHNI :)

Nor I.  I suspect so, but we'll have to experiment (or get someone to 
prove the math).


>>>  Spiro has 5 kinds of points.
>>
>>  So, in that respect, spiro is more akin to a multiple-command path segment
>>  than to one particular command such as a cubic Bézier.  In other words, my
>>  experiment with [1] using a combination of (simulated) Catmull-Rom curves
>>  combined with Linetos is rather similar to spiro.
>
> Without a screencap on your blog, I'm not sure how you authored the
> image there.

Just view the source!  (To view dynamically-generated SVG, select-all 
with Ctrl+A, and view selection source, at least in Firefox.)

Here's the "simulated" path:

<path id="spline" stroke-width="2" stroke="red" fill="none" 
stroke-linecap="round" d="M183,18 R135,18 89,33 40,73 25,99 23,112 
34,115 64,102 78,92 84,76 107,54 147,54 187,86 196,132
  L196,201 R158,204 120,210 56,229 17,261 9,309 28,352 92,371 164,357 
202,334 209,350 226,371 249,374 296,359 330,344 340,339 342,326 332,322 
317,330 294,336 267,316 260,279 259,203 261,117 254,63 220,30 183,18
  M195,224 R161,227 125,234 96,247 77,270 82,311 110,335 154,334 198,309
  L196,274 195,225"/>

And here's what my code turns it into to render it in Béziers:

<path id="spline" stroke-width="2" stroke="red" fill="none" 
stroke-linecap="round" d="M183,18 C175,18 150.6,15.5 135,18 C119.3,20.5 
104.83,23.832 89,3 C73.167,42.164 50.64,62 40,73 C29.32,84 27.832,92.5 
25,99 C22.168,105.5 21.5,109.3 23,112 C24.5,114.67 27.168,116.67 34,115 
C40.836,113.3 56.64,105.83 64,102 C71.3,98.167 74.67,96.3 78,92 
C81.3,87.67 79.167,82.3 84,76 C88.83,69.67 96.5,57.64 107,54 
C117.5,50.36 13.6,48.64 147,54 C160.34,59.36 178.834,73 187,86 
C195.16,99 194.5,124.3 196,132  L196,201 C189.6,201.5 170.6,202.5 
158,204 C145.34,205.5 137,205.834 120,210 C103,214.16 73.167,220.5 
56,229 C38.836,237.5 24.832,247.6 17,261 C9.16,274.3 7.167,293.83 9,309 
C10.834,324.167 14.16,341.67 28,352 C41.836,362.3 69.3,370.167 92,371 
C114.67,371.83 145.6,363.167 164,357 C182.34,350.83 194.5,35.167 202,34 
C209.5,32.83 205,343.83 209,350 C213,356.167 219.34,367 226,371 
C232.6,375 237.34,376 249,374 C260.67,372 282.5,364 296,359 C309.5,354 
322.67,347.3 30,344 C37.3,340.67 38,342 340,39 C342,36 343.3,328.83 
342,326 C340.67,323.167 36.167,321.3 32,322 C327.83,322.67 323.3,327.67 
317,30 C310.67,32.3 302.3,38.3 294,36 C285.67,3.67 272.67,325.5 267,316 
C261.3,306.5 261.3,297.83 260,279 C258.67,260.167 258.83,230 259,203 
C259.167,176 261.83,140.34 261,117 C260.167,93.67 260.83,77.5 254,63 
C247.16,48.5 231.834,37.5 220,30 C208.16,22.5 189.16,20 183,18  M195,224 
C189.34,224.5 172.6,225.34 161,227 C149.34,228.6 135.834,230.6 125,234 
C114.167,237.34 104,241 96,247 C88,253 79.3,259.3 77,270 C74.67,280.67 
76.5,300.167 82,311 C87.5,321.83 98,31.167 110,35 C122,38.83 139.34,38.3 
154,34 C168.6,329.67 190.6,313.167 198,309  L196,274 195,225"/>


> It strikes me that a mature authoring environment for CR curves looks
> a lot like the "auto smooth node" Inkscape point type.
>
> The questions to me are:
>
> Are CR curves as smooth as Spiro curves for the same number of points? - No.

Not by a long shot!  Try my toy Catmull-Rom editor [1] to see for 
yourself.  The only guarantees are:
a) the curves will pass through each point, in a unique and 
reproduceable manner
b) the curves will be fairly tight, smooth interpolations between points
c) adding each additional point will only change the curve for that 
segment and the segment before it, not segments 2 or more back.

However, that may be enough for many authoring cases.  While the curves 
aren't as elegant as spiros, they are more predictable.


> Are CR curves as easy to author smooth curves with as Spiro curves? -
> Yes, guess so based on Inkscape auto smooth nodes, unlike normal
> Beziers.

I think there are advantages and disadvantages to ease of authoring for 
Catmull-Roms vs spiros.  But both are relatively easy and intuitive, 
compared to Béziers.


> Do CR curves interpolate as smoothly as Spiro curves? - I don't know.

I suspect so, if we are talking about the point above on the 
interpolation masters.  But I don't know that for certain.

[1] http://schepers.cc/svg/path/dotty.svg

Regards-
-Doug Schepers
W3C Team Contact, SVG and WebApps WGs

Received on Thursday, 15 July 2010 17:54:17 UTC