<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>The Algorithmist</title>
	<atom:link href="http://algorithmist.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://algorithmist.wordpress.com</link>
	<description></description>
	<lastBuildDate>Mon, 09 Nov 2009 13:08:40 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='algorithmist.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/6f31327ab807bdc45f38a67ab579208f?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>The Algorithmist</title>
		<link>http://algorithmist.wordpress.com</link>
	</image>
			<item>
		<title>Going Underground for a While</title>
		<link>http://algorithmist.wordpress.com/2009/11/09/going-underground-for-a-while/</link>
		<comments>http://algorithmist.wordpress.com/2009/11/09/going-underground-for-a-while/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 13:08:40 +0000</pubDate>
		<dc:creator>algorithmist</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://algorithmist.wordpress.com/?p=1823</guid>
		<description><![CDATA[Just returned from a long business trip.  I&#8217;ve started a new and pretty intense gig.  I&#8217;m back to work with the Flex framework for the first time in two years and already doing Google Finance-style data visualizations.  I&#8217;ll be extremely busy for the next two weeks and then go on vacation for two weeks.  I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=algorithmist.wordpress.com&blog=857842&post=1823&subd=algorithmist&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Just returned from a long business trip.  I&#8217;ve started a new and pretty intense gig.  I&#8217;m back to work with the Flex framework for the first time in two years and already doing Google Finance-style data visualizations.  I&#8217;ll be extremely busy for the next two weeks and then go on vacation for two weeks.  I might blog a bit during vacation, but don&#8217;t expect much of anything between now and the end of the year.</p>
<p>Thanks.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/algorithmist.wordpress.com/1823/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/algorithmist.wordpress.com/1823/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/algorithmist.wordpress.com/1823/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/algorithmist.wordpress.com/1823/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/algorithmist.wordpress.com/1823/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/algorithmist.wordpress.com/1823/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/algorithmist.wordpress.com/1823/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/algorithmist.wordpress.com/1823/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/algorithmist.wordpress.com/1823/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/algorithmist.wordpress.com/1823/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=algorithmist.wordpress.com&blog=857842&post=1823&subd=algorithmist&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://algorithmist.wordpress.com/2009/11/09/going-underground-for-a-while/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c3dbb3ae20bd7175acece4154c978a77?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">algorithmist</media:title>
		</media:content>
	</item>
		<item>
		<title>Degrafa Cardinal Spline</title>
		<link>http://algorithmist.wordpress.com/2009/10/20/degrafa-cardinal-spline/</link>
		<comments>http://algorithmist.wordpress.com/2009/10/20/degrafa-cardinal-spline/#comments</comments>
		<pubDate>Tue, 20 Oct 2009 12:41:06 +0000</pubDate>
		<dc:creator>algorithmist</dc:creator>
				<category><![CDATA[Degrafa]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Cardinal Spline]]></category>
		<category><![CDATA[Geometry]]></category>
		<category><![CDATA[spline]]></category>

		<guid isPermaLink="false">http://algorithmist.wordpress.com/?p=1812</guid>
		<description><![CDATA[The Degrafa Cardinal spline is now available from the Origin branch.  Usage is very similar to the Catmull-Rom spline with the exception of the tension parameter.  The Cardinal spline is based on the C-R code base, so it supports closure.  The algorithm is the same as the C-R spline, so it is best used for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=algorithmist.wordpress.com&blog=857842&post=1812&subd=algorithmist&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>The Degrafa Cardinal spline is now available from the Origin branch.  Usage is very similar to the Catmull-Rom spline with the exception of the tension parameter.  The Cardinal spline is based on the C-R code base, so it supports closure.  The algorithm is the same as the C-R spline, so it is best used for tensions in the [0,1] range.  For example,</p>
<p>&lt;mx:Application xmlns:mx=&#8221;http://www.adobe.com/2006/mxml&#8221;<br />
xmlns:comp=&#8221;components.*&#8221;<br />
xmlns:degrafa=&#8221;com.degrafa.*&#8221;<br />
xmlns:paint=&#8221;com.degrafa.paint.*&#8221;<br />
xmlns:geom=&#8221;com.degrafa.geometry.*&#8221;<br />
xmlns:splines=&#8221;com.degrafa.geometry.splines.*&#8221;<br />
layout=&#8221;absolute&#8221;<br />
width=&#8221;600&#8243; height=&#8221;500&#8243;<br />
pageTitle=&#8221;Cardinal Spline&#8221;<br />
applicationComplete=&#8221;test()&#8221; viewSourceURL=&#8221;srcview/index.html&#8221;&gt;</p>
<pre>.</pre>
<pre>.</pre>
<pre>.</pre>
<p>&lt;paint:SolidStroke id=&#8221;redstroke&#8221; weight=&#8221;2&#8243; color=&#8221;#FF0000&#8243;/&gt;</p>
<p>&lt;splines:CardinalSpline id=&#8221;crspline&#8221; graphicsTarget=&#8221;{[splineLayer1]}&#8221; stroke=&#8221;{redstroke}&#8221; knots=&#8221;453,159 350,302 218,202 146,297 400,110&#8243; tension=&#8221;0&#8243; closed=&#8221;true&#8221; /&gt;</p>
<p>produces the same fit as the Catmull-Rom spline,</p>
<div id="attachment_1813" class="wp-caption alignnone" style="width: 330px"><img class="size-full wp-image-1813" title="cardspline1" src="http://algorithmist.files.wordpress.com/2009/10/cardspline1.jpg?w=320&#038;h=240" alt="Closure with Zero Tension" width="320" height="240" /><p class="wp-caption-text">Closure with Zero Tension</p></div>
<p>Changing the tension to 1 &#8216;pulls&#8217; the spline to the point where the fit is line-to-line,</p>
<p>&lt;splines:CardinalSpline id=&#8221;crspline&#8221; graphicsTarget=&#8221;{[splineLayer1]}&#8221; stroke=&#8221;{redstroke}&#8221; knots=&#8221;453,159 350,302 218,202 146,297 400,110&#8243; tension=&#8221;1&#8243; closed=&#8221;true&#8221; /&gt;</p>
<div id="attachment_1814" class="wp-caption alignnone" style="width: 330px"><img class="size-full wp-image-1814" title="cardspline2" src="http://algorithmist.files.wordpress.com/2009/10/cardspline21.jpg?w=320&#038;h=239" alt="Closure with Tension = 1" width="320" height="239" /><p class="wp-caption-text">Closure with Tension = 1</p></div>
<p>Tensions in the range -1 to 3 are supported.  Negative tension &#8216;loosens&#8217; the fit.  Tensions greater than 1 cause the spline to loop in on itself going into and out of each knot.  The effect at initial and terminal knots depends on how the auxiliary control points are chosen (same options as the C-R spline).</p>
<p>Splines are open by default.  For example,</p>
<p>&lt;splines:CardinalSpline id=&#8221;crspline&#8221; graphicsTarget=&#8221;{[splineLayer1]}&#8221; stroke=&#8221;{redstroke}&#8221; knots=&#8221;453,159 350,302 218,202 146,297 400,110&#8243; tension=&#8221;-0.5&#8243; /&gt;</p>
<p>produces the following</p>
<div id="attachment_1815" class="wp-caption alignnone" style="width: 330px"><img class="size-full wp-image-1815" title="cardspline3" src="http://algorithmist.files.wordpress.com/2009/10/cardspline3.jpg?w=320&#038;h=237" alt="Loosening the tension in a Cardinal spline" width="320" height="237" /><p class="wp-caption-text">Loosening the tension in a Cardinal spline</p></div>
<p>I&#8217;m preparing for a long business trip, so posts and Degrafa updates will be sparse over the next several weeks.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/algorithmist.wordpress.com/1812/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/algorithmist.wordpress.com/1812/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/algorithmist.wordpress.com/1812/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/algorithmist.wordpress.com/1812/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/algorithmist.wordpress.com/1812/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/algorithmist.wordpress.com/1812/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/algorithmist.wordpress.com/1812/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/algorithmist.wordpress.com/1812/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/algorithmist.wordpress.com/1812/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/algorithmist.wordpress.com/1812/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=algorithmist.wordpress.com&blog=857842&post=1812&subd=algorithmist&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://algorithmist.wordpress.com/2009/10/20/degrafa-cardinal-spline/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c3dbb3ae20bd7175acece4154c978a77?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">algorithmist</media:title>
		</media:content>

		<media:content url="http://algorithmist.files.wordpress.com/2009/10/cardspline1.jpg" medium="image">
			<media:title type="html">cardspline1</media:title>
		</media:content>

		<media:content url="http://algorithmist.files.wordpress.com/2009/10/cardspline21.jpg" medium="image">
			<media:title type="html">cardspline2</media:title>
		</media:content>

		<media:content url="http://algorithmist.files.wordpress.com/2009/10/cardspline3.jpg" medium="image">
			<media:title type="html">cardspline3</media:title>
		</media:content>
	</item>
		<item>
		<title>Degrafa Bezier X at Y Test Program</title>
		<link>http://algorithmist.wordpress.com/2009/10/16/degrafa-bezier-x-at-y-test-program/</link>
		<comments>http://algorithmist.wordpress.com/2009/10/16/degrafa-bezier-x-at-y-test-program/#comments</comments>
		<pubDate>Fri, 16 Oct 2009 12:46:21 +0000</pubDate>
		<dc:creator>algorithmist</dc:creator>
				<category><![CDATA[Degrafa]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Degrafa Bezier Flex Actionscript]]></category>

		<guid isPermaLink="false">http://algorithmist.wordpress.com/?p=1798</guid>
		<description><![CDATA[There is not much difference from the demo of the Bezier x-at-y method from the previously posted y-at-x demos.  Here is the MXML for the test case.  Most of the heavy lifting is in the displayXatY() method.  Study that and you should have a pretty good understanding of how the Bezier x-at-y method is applied.
If [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=algorithmist.wordpress.com&blog=857842&post=1798&subd=algorithmist&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>There is not much difference from the demo of the Bezier x-at-y method from the previously posted y-at-x demos.  Here is the MXML for the test case.  Most of the heavy lifting is in the displayXatY() method.  Study that and you should have a pretty good understanding of how the Bezier x-at-y method is applied.</p>
<p>If time allows, I&#8217;ll try to cook up a demo illustrating how to align sprites along the contour of a Bezier curve, but that will most likely wait until after I return from my upcoming business trip.</p>
<p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;utf-8&#8243;?&gt;<br />
&lt;mx:Application<br />
xmlns:mx=&#8221;http://www.adobe.com/2006/mxml&#8221;<br />
xmlns:geom=&#8221;components.*&#8221;<br />
xmlns=&#8221;http://www.degrafa.com/2007&#8243;<br />
layout=&#8221;absolute&#8221;<br />
width=&#8221;600&#8243; height=&#8221;500&#8243;<br />
pageTitle=&#8221;Degrafa Advanced Cubic Bezier X at Y&#8221;<br />
applicationComplete=&#8221;test()&#8221; xmlns:degrafa=&#8221;http://www.degrafa.com/2007&#8243; viewSourceURL=&#8221;srcview/index.html&#8221;&gt;</p>
<p>&lt;mx:Style source=&#8221;assets/style/style.css&#8221;/&gt;<br />
&lt;mx:Canvas id=&#8221;background&#8221; x=&#8221;50&#8243; y=&#8221;90&#8243; width=&#8221;500&#8243; height=&#8221;320&#8243; backgroundColor=&#8221;#FFFFFF&#8221; /&gt;<br />
&lt;mx:Label text=&#8221;Adv. Cubic Bezier X-at-Y&#8221; x=&#8221;250&#8243; y=&#8221;30&#8243; width=&#8221;300&#8243; styleName=&#8221;title&#8221;/&gt;</p>
<p>&lt;mx:Canvas id=&#8221;bezierLayer&#8221; /&gt;<br />
&lt;mx:Canvas id=&#8221;boundsLayer&#8221; /&gt;</p>
<p>&lt;geom:InteractivePoint id=&#8221;pointA&#8221; x=&#8221;90&#8243; y=&#8221;250&#8243; pointLabel=&#8221;A&#8221; radius=&#8221;5&#8243; color=&#8221;0&#215;00ff00&#8243; width=&#8221;100&#8243; height=&#8221;20&#8243; /&gt;<br />
&lt;geom:InteractivePoint id=&#8221;pointB&#8221; x=&#8221;150&#8243; y=&#8221;150&#8243; pointLabel=&#8221;B&#8221; radius=&#8221;5&#8243; color=&#8221;0&#215;00ff00&#8243; width=&#8221;100&#8243; height=&#8221;20&#8243; /&gt;<br />
&lt;geom:InteractivePoint id=&#8221;pointC&#8221; x=&#8221;290&#8243; y=&#8221;200&#8243; pointLabel=&#8221;C&#8221; radius=&#8221;5&#8243; color=&#8221;0&#215;00ff00&#8243; width=&#8221;100&#8243; height=&#8221;20&#8243; /&gt;<br />
&lt;geom:InteractivePoint id=&#8221;pointD&#8221; x=&#8221;360&#8243; y=&#8221;300&#8243; pointLabel=&#8221;D&#8221; radius=&#8221;5&#8243; color=&#8221;0&#215;00ff00&#8243; width=&#8221;100&#8243; height=&#8221;20&#8243; /&gt;</p>
<p><strong>&lt;AdvancedCubicBezier id=&#8221;bezier&#8221; graphicsTarget=&#8221;{[bezierLayer]}&#8221;&gt;<br />
&lt;stroke&gt;<br />
&lt;SolidStroke weight=&#8221;2&#8243; color=&#8221;#0000FF&#8221;/&gt;<br />
&lt;/stroke&gt;<br />
&lt;/AdvancedCubicBezier&gt;</strong></p>
<p>&lt;mx:Label x=&#8221;50&#8243; y=&#8221;440&#8243; text=&#8221;" width=&#8221;500&#8243; fontSize=&#8221;12&#8243; color=&#8221;#FFFFFF&#8221; id=&#8221;__x1__&#8221;/&gt;<br />
&lt;mx:Label x=&#8221;50&#8243; y=&#8221;460&#8243; text=&#8221;" width=&#8221;500&#8243; fontSize=&#8221;12&#8243; color=&#8221;#FFFFFF&#8221; id=&#8221;__x2__&#8221;/&gt;<br />
&lt;mx:Label x=&#8221;50&#8243; y=&#8221;480&#8243; text=&#8221;" width=&#8221;500&#8243; fontSize=&#8221;12&#8243; color=&#8221;#FFFFFF&#8221; id=&#8221;__x3__&#8221;/&gt;</p>
<p>&lt;mx:VSlider x=&#8221;500&#8243; y=&#8221;95&#8243; height=&#8221;310&#8243; id=&#8221;__mySlider__&#8221; allowTrackClick=&#8221;false&#8221; minimum=&#8221;0&#8243; maximum=&#8221;1&#8243; enabled=&#8221;false&#8221; change=&#8221;displayXatY(event)&#8221; liveDragging=&#8221;true&#8221;/&gt;</p>
<p>&lt;mx:Script&gt;<br />
&lt;![CDATA[<br />
import mx.events.PropertyChangeEvent;<br />
import mx.events.SliderEvent;</p>
<p>import com.degrafa.GraphicPointEX;<br />
import com.degrafa.core.collections.GraphicPointCollection;</p>
<p>private var __yMin:Number;<br />
private var __yMax:Number;</p>
<p>private function test():void<br />
{<br />
// restrict dragging for each point<br />
var bounds:Rectangle = new Rectangle(background.x, background.y, background.width, background.height);<br />
pointA.restrict      = bounds;<br />
pointB.restrict      = bounds;<br />
pointC.restrict      = bounds;<br />
pointD.restrict      = bounds;</p>
<p>// actions when a property is changed on any InteractivePoint<br />
pointA.addEventListener(PropertyChangeEvent.PROPERTY_CHANGE, onPropertyChanged);<br />
pointB.addEventListener(PropertyChangeEvent.PROPERTY_CHANGE, onPropertyChanged);<br />
pointC.addEventListener(PropertyChangeEvent.PROPERTY_CHANGE, onPropertyChanged);<br />
pointD.addEventListener(PropertyChangeEvent.PROPERTY_CHANGE, onPropertyChanged);</p>
<p>// assign the quad. bezier data from script<br />
assignBezierInterpolationPoints();</p>
<p>__mySlider__.alpha = 0.2;<br />
__yMin             = __mySlider__.y;<br />
__yMax             = __mySlider__.y + __mySlider__.height;<br />
}</p>
<p>private function assignBezierInterpolationPoints():void<br />
{<br />
// property changes trigger redraw<br />
var params:Array = bezier.interpolate( [new Point(pointA.x, pointA.y), new Point(pointB.x, pointB.y),<br />
new Point(pointC.x, pointC.y), new Point(pointD.x, pointD.y)] );<br />
}</p>
<p>private function onPropertyChanged(_e:PropertyChangeEvent):void<br />
{<br />
switch( _e.property )<br />
{<br />
case InteractivePoint.MOUSE_DOWN:<br />
__mySlider__.enabled = false;<br />
__mySlider__.alpha   = 0.2;<br />
boundsLayer.graphics.clear();</p>
<p>addEventListener(Event.ENTER_FRAME, onPointMove);<br />
break;</p>
<p>case InteractivePoint.MOUSE_UP:<br />
removeEventListener(Event.ENTER_FRAME, onPointMove);</p>
<p>// enable slider<br />
__mySlider__.enabled = true;<br />
__mySlider__.alpha   = 1.0;<br />
__mySlider__.value   = 0;<br />
break;<br />
}<br />
}</p>
<p>// redraw control points and bezier curve when an InteractivePoint is moved<br />
private function onPointMove(_e:Event):void<br />
{<br />
assignBezierInterpolationPoints();<br />
}</p>
<p>// display X at Y<br />
<strong>private function displayXatY(_e:SliderEvent):void</strong><br />
{<br />
// line does not track the middle of the thumb, but the slider value<br />
var myY:Number   = (1-_e.value)*__yMax + _e.value*__yMin &#8211; bezierLayer.y;<br />
<strong>var values:Array = bezier.xAtY(myY);</strong></p>
<p>__x1__.text = &#8220;&#8221;;<br />
__x2__.text = &#8220;&#8221;;<br />
__x3__.text = &#8220;&#8221;;</p>
<p>var g:Graphics = boundsLayer.graphics;<br />
g.clear();<br />
g.lineStyle(1,0xff0000);<br />
g.moveTo( __mySlider__.x+10, myY + bezierLayer.y);<br />
g.lineTo( background.x     , myY + bezierLayer.y);</p>
<p>if( values.length != 0 )<br />
{<br />
var o:Object   = values[0];<br />
var myX:Number = o.x;<br />
__x1__.text    = &#8220;t: &#8221; + o.t + &#8220;, x: &#8221; + myX;</p>
<p>g.beginFill(0xff0000);<br />
g.drawCircle(myX, bezierLayer.y + myY, 4);</p>
<p>if( values.length &gt; 1 )<br />
{<br />
o           = values[1];<br />
myX         = o.x;<br />
__x2__.text = &#8220;t: &#8221; + o.t + &#8220;, x: &#8221; + myX;</p>
<p>g.beginFill(0xff0000);<br />
g.drawCircle(myX, bezierLayer.y + myY, 4);<br />
}</p>
<p>if( values.length == 3 )<br />
{<br />
o           = values[2];<br />
myX         = o.x;<br />
__x3__.text = &#8220;t: &#8221; + o.t + &#8220;, x: &#8221; + myX;</p>
<p>g.beginFill(0xff0000);<br />
g.drawCircle(myX, bezierLayer.y + myY, 4);<br />
}<br />
}<br />
}</p>
<p>]]&gt;<br />
&lt;/mx:Script&gt;</p>
<p>&lt;/mx:Application&gt;</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/algorithmist.wordpress.com/1798/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/algorithmist.wordpress.com/1798/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/algorithmist.wordpress.com/1798/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/algorithmist.wordpress.com/1798/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/algorithmist.wordpress.com/1798/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/algorithmist.wordpress.com/1798/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/algorithmist.wordpress.com/1798/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/algorithmist.wordpress.com/1798/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/algorithmist.wordpress.com/1798/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/algorithmist.wordpress.com/1798/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=algorithmist.wordpress.com&blog=857842&post=1798&subd=algorithmist&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://algorithmist.wordpress.com/2009/10/16/degrafa-bezier-x-at-y-test-program/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c3dbb3ae20bd7175acece4154c978a77?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">algorithmist</media:title>
		</media:content>
	</item>
		<item>
		<title>Bezier Y at X Algorithm</title>
		<link>http://algorithmist.wordpress.com/2009/10/15/bezier-y-at-x-algorithm/</link>
		<comments>http://algorithmist.wordpress.com/2009/10/15/bezier-y-at-x-algorithm/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 12:54:46 +0000</pubDate>
		<dc:creator>algorithmist</dc:creator>
				<category><![CDATA[Degrafa]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Bezier]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://algorithmist.wordpress.com/?p=1787</guid>
		<description><![CDATA[A few requests for the algorithm behind the Bezier y-at-x and x-at-y methods have been received.  The code is self-contained in the com.degrafa.geometry.AdvancedQuadraticBezier and AdvancedCubicBezier classes.  Both classes accept control points in their constructors and use classes from com.degrafa.utilities.math .  The latter classes are independent from any internal Degrafa architecture.  So, people who maintain their [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=algorithmist.wordpress.com&blog=857842&post=1787&subd=algorithmist&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>A few requests for the algorithm behind the Bezier y-at-x and x-at-y methods have been received.  The code is self-contained in the com.degrafa.geometry.AdvancedQuadraticBezier and AdvancedCubicBezier classes.  Both classes accept control points in their constructors and use classes from com.degrafa.utilities.math .  The latter classes are independent from any internal Degrafa architecture.  So, people who maintain their own Bezier class libraries have a path to include the y-at-x and x-at-y capability.</p>
<p>Finding the y-coordinates at a given x or the x-coordinates at a given y is an exercise in root-finding.  Suppose the Bezier curve is B(t) which is quadratic or cubic in t.  For the cubic Bezier, the vector equation for the curve produces two scalar equations, one for the x-coordinates and one for the y-coordinates, i.e.</p>
<p>B<sub>x</sub>(t) = c<sub>0x</sub> + c<sub>1x</sub>t + c<sub>2x</sub>t<sup>2</sup> + c<sub>3x</sub>t<sup>3</sup></p>
<p>B<sub>y</sub>(t) = c<sub>0y</sub> + c<sub>1y</sub>t + c<sub>2y</sub>t<sup>2</sup> + c<sub>3y</sub>t<sup>3</sup></p>
<p>For the y-at-x case, the required y-coordinates are found at the t-parameters corresponding to the intersection of B(t) with the vertical line x = a, or</p>
<p>c<sub>0x</sub> + c<sub>1x</sub>t + c<sub>2x</sub>t<sup>2</sup> + c<sub>3x</sub>t<sup>3</sup> &#8211; a = 0</p>
<p>The problem reduces to one of finding roots of a cubic polynomial. This starts by finding one root.  Synthetic division is used to factor out the single root leaving a quadratic polynomial.  The two possible roots of that polynomial are found with the venerable quadratic formula.  Only roots in [0,1] are valid solutions to the y-at-x problem.  The roots (values of t) are used to compute the y-coordinates using the equation for B<sub>y</sub>(t).  With a quadratic Bezier, roots are found directly with the quadratic formula.</p>
<p>The x-at-y problem is similar in that the required x-coordinates are the intersection of B(t) with the horizontal line y = a.  There is one degenerate case where the Bezier curve is a segment of a horizontal or vertical line and the single parameter describing the line is the input value.  For example, a cubic Bezier curve is the line x = a and the y-coordinates for x = a are desired.  Theoretically, there are an infinite number.  The Degrafa code does not currently handle this case.  Some argue that no values should be returned while otheres argue that perhaps t = 0, t = 1/2 and t = 1 should be returned.</p>
<p>Given the rarity of this case actually occurring, the argument is postponed in lieu of more important developments.  Tomorrow, I&#8217;ll post some code from the demos.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/algorithmist.wordpress.com/1787/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/algorithmist.wordpress.com/1787/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/algorithmist.wordpress.com/1787/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/algorithmist.wordpress.com/1787/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/algorithmist.wordpress.com/1787/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/algorithmist.wordpress.com/1787/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/algorithmist.wordpress.com/1787/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/algorithmist.wordpress.com/1787/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/algorithmist.wordpress.com/1787/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/algorithmist.wordpress.com/1787/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=algorithmist.wordpress.com&blog=857842&post=1787&subd=algorithmist&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://algorithmist.wordpress.com/2009/10/15/bezier-y-at-x-algorithm/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c3dbb3ae20bd7175acece4154c978a77?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">algorithmist</media:title>
		</media:content>
	</item>
		<item>
		<title>New Degrafa Bezier Methods</title>
		<link>http://algorithmist.wordpress.com/2009/10/14/new-degrafa-bezier-methods/</link>
		<comments>http://algorithmist.wordpress.com/2009/10/14/new-degrafa-bezier-methods/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 12:49:42 +0000</pubDate>
		<dc:creator>algorithmist</dc:creator>
				<category><![CDATA[Degrafa]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Bezier]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://algorithmist.wordpress.com/?p=1779</guid>
		<description><![CDATA[I have received a couple requests for x-at-y methods in the advanced quadratic and cubic Bezier classes to complement the existing y-at-x methods.  Fortunately, the algorithm is the same, just a different set of coefficients, so it was an easy addition.
The x-at-y problem is typically used to distribute sprites left-to-right and top-to-bottom along the contour [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=algorithmist.wordpress.com&blog=857842&post=1779&subd=algorithmist&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I have received a couple requests for x-at-y methods in the advanced quadratic and cubic Bezier classes to complement the existing y-at-x methods.  Fortunately, the algorithm is the same, just a different set of coefficients, so it was an easy addition.</p>
<p>The x-at-y problem is typically used to distribute sprites left-to-right and top-to-bottom along the contour of a Bezier curve.  The y-coordinate of the first sprite is fixed.  The horizontal location is determined by the x-coordinate of the Bezier curve corresponding to the specified y-coordinate (plus some offset).  Sprites are &#8217;stacked&#8217; along the contour of the curve by incrementing the y-coordinate based on the height of the previous sprite plus some offset, then repeating the algorithm.</p>
<p>The following diagrams illustrate the quadratic and cubic cases.</p>
<div id="attachment_1780" class="wp-caption alignnone" style="width: 330px"><img class="size-full wp-image-1780" title="qbxaty" src="http://algorithmist.files.wordpress.com/2009/10/qbxaty.jpg?w=320&#038;h=239" alt="Quadratic Bezier x-at-y" width="320" height="239" /><p class="wp-caption-text">Quadratic Bezier x-at-y</p></div>
<div id="attachment_1781" class="wp-caption alignnone" style="width: 330px"><img class="size-full wp-image-1781" title="cbxaty" src="http://algorithmist.files.wordpress.com/2009/10/cbxaty.jpg?w=320&#038;h=242" alt="Cubic Bezier x-at-y" width="320" height="242" /><p class="wp-caption-text">Cubic Bezier x-at-y</p></div>
<p>These methods are in the AdvancedQuadraticBezier and AdvancedCubicBezier classes.  Update SVN and enjoy.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/algorithmist.wordpress.com/1779/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/algorithmist.wordpress.com/1779/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/algorithmist.wordpress.com/1779/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/algorithmist.wordpress.com/1779/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/algorithmist.wordpress.com/1779/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/algorithmist.wordpress.com/1779/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/algorithmist.wordpress.com/1779/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/algorithmist.wordpress.com/1779/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/algorithmist.wordpress.com/1779/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/algorithmist.wordpress.com/1779/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=algorithmist.wordpress.com&blog=857842&post=1779&subd=algorithmist&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://algorithmist.wordpress.com/2009/10/14/new-degrafa-bezier-methods/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c3dbb3ae20bd7175acece4154c978a77?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">algorithmist</media:title>
		</media:content>

		<media:content url="http://algorithmist.files.wordpress.com/2009/10/qbxaty.jpg" medium="image">
			<media:title type="html">qbxaty</media:title>
		</media:content>

		<media:content url="http://algorithmist.files.wordpress.com/2009/10/cbxaty.jpg" medium="image">
			<media:title type="html">cbxaty</media:title>
		</media:content>
	</item>
		<item>
		<title>Cardinal Splines Part 5</title>
		<link>http://algorithmist.wordpress.com/2009/10/08/cardinal-splines-part-5/</link>
		<comments>http://algorithmist.wordpress.com/2009/10/08/cardinal-splines-part-5/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 12:50:11 +0000</pubDate>
		<dc:creator>algorithmist</dc:creator>
				<category><![CDATA[Degrafa]]></category>
		<category><![CDATA[Math]]></category>

		<guid isPermaLink="false">http://algorithmist.wordpress.com/?p=1769</guid>
		<description><![CDATA[Continuing from part 4 of this series, we are looking at tension values outside the range of zero to one.  When T is negative, then s = (1-T)/2 increases from 1/2 and grows without limit as T becomes larger negative.  So, what happens for large values of s?
Using the same four knots and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=algorithmist.wordpress.com&blog=857842&post=1769&subd=algorithmist&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Continuing from <a href="http://algorithmist.wordpress.com/2009/10/06/cardinal-splines-part-4/" target="_blank">part 4 of this series</a>, we are looking at tension values outside the range of zero to one.  When T is negative, then s = (1-T)/2 increases from 1/2 and grows without limit as T becomes larger negative.  So, what happens for large values of s?</p>
<p>Using the same four knots and the same equation from part 4 of this series, P(0.5) serves as an approximate representation of the midpoint of the curve from P<sub>2</sub> to P<sub>3</sub>.  The curve is not naturally arc-length parameterized, so P(0.5) is a convenient point on the curve &#8216;away&#8217; from both endpoints.</p>
<p>The expectation is that as s increases, the curve tends to follow the tangents more closely.  Now,</p>
<p>P(0.5) = s/8[(P<sub>3</sub> - P<sub>1</sub>) + (P<sub>2</sub> - P<sub>4</sub>)] + 0.5(P<sub>2</sub> + P<sub>3</sub>)</p>
<p>The second term is the midpoint between P<sub>2</sub> and P<sub>3</sub>.  If P<sup>t</sup>(t) denotes the tangent, the above equation becomes</p>
<p>P(0.5) = s/8[P<sup>t</sup>(0) - P<sup>t</sup>(1)] + 0.5(P<sub>2</sub> + P<sub>3</sub>)</p>
<p>The first term is the difference between the two tangents, multiplied by a constant term that grows without bound.  The endpoint of this vector is added to the midpoint between P<sub>2</sub> and P<sub>3</sub>.  That means that P(0.5) is pushed arbitrarily far away from the fixed point 0.5(P<sub>2</sub> + P<sub>3</sub>) as s increases without bound.</p>
<p>The following diagram shows what happens when s = 1 (corresponding to T = -1).  The red curve is the Degrafa Catmull-Rom spline (s = 1/2) and the blue curve is the Cardinal spline with s = 1.  Note the tendency for the curve to stay closer to the tangents at each join.  Point reflection is used to compute the auxiliary points at the beginning and end (i.e. before P<sub>1</sub> and after P<sub>4</sub>).</p>
<div id="attachment_1772" class="wp-caption alignnone" style="width: 330px"><img class="size-full wp-image-1772" title="cspline3" src="http://algorithmist.files.wordpress.com/2009/10/cspline3.jpg?w=320&#038;h=238" alt="Cardinal Spline s = 1" width="320" height="238" /><p class="wp-caption-text">Cardinal Spline s = 1</p></div>
<p>A cubic curve only has so much flexibility in terms of inflection.  Driving T too far negative (and thus s too far away from 1/2) can cause strange behavior as shown in the case where s = 2, below.</p>
<div id="attachment_1773" class="wp-caption alignnone" style="width: 330px"><img class="size-full wp-image-1773" title="cspline4" src="http://algorithmist.files.wordpress.com/2009/10/cspline4.jpg?w=320&#038;h=241" alt="Cardinal Spline s = 2" width="320" height="241" /><p class="wp-caption-text">Cardinal Spline s = 2</p></div>
<p>Exact behavior varies depending on how the auxiliary points are chosen.</p>
<p>The case where T &gt; 1 drives s negative.  This reverses the role of in- and out-tangents.  This causes the spline to loop around itself at each join.  Look at the comments from part 4 for a link to a good demo of this case.</p>
<p>These extreme cases serve as poor interpolants, but can be used to draw cool-looking curves.  So, there is some justification for allowing tension values outside the typical [0,1] range.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/algorithmist.wordpress.com/1769/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/algorithmist.wordpress.com/1769/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/algorithmist.wordpress.com/1769/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/algorithmist.wordpress.com/1769/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/algorithmist.wordpress.com/1769/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/algorithmist.wordpress.com/1769/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/algorithmist.wordpress.com/1769/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/algorithmist.wordpress.com/1769/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/algorithmist.wordpress.com/1769/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/algorithmist.wordpress.com/1769/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=algorithmist.wordpress.com&blog=857842&post=1769&subd=algorithmist&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://algorithmist.wordpress.com/2009/10/08/cardinal-splines-part-5/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c3dbb3ae20bd7175acece4154c978a77?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">algorithmist</media:title>
		</media:content>

		<media:content url="http://algorithmist.files.wordpress.com/2009/10/cspline3.jpg" medium="image">
			<media:title type="html">cspline3</media:title>
		</media:content>

		<media:content url="http://algorithmist.files.wordpress.com/2009/10/cspline4.jpg" medium="image">
			<media:title type="html">cspline4</media:title>
		</media:content>
	</item>
		<item>
		<title>Cardinal Splines Part 4</title>
		<link>http://algorithmist.wordpress.com/2009/10/06/cardinal-splines-part-4/</link>
		<comments>http://algorithmist.wordpress.com/2009/10/06/cardinal-splines-part-4/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 13:03:35 +0000</pubDate>
		<dc:creator>algorithmist</dc:creator>
				<category><![CDATA[Degrafa]]></category>
		<category><![CDATA[Math]]></category>
		<category><![CDATA[Cardinal Spline]]></category>
		<category><![CDATA[Splines]]></category>

		<guid isPermaLink="false">http://algorithmist.wordpress.com/?p=1754</guid>
		<description><![CDATA[Continuing from part 3 of this series, a formal tension parameter, T = 1-2s, was introduced.  All we noted about tension was that T=0 corresponds to s = 1/2.  At s=1/2, the Cardinal spline takes on the form of the more familiar Catmull-Rom spline.  The Catmull-Rom spline may, however, be derived independently [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=algorithmist.wordpress.com&blog=857842&post=1754&subd=algorithmist&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Continuing from <a href="http://algorithmist.wordpress.com/2009/10/01/cardinal-splines-part-3/" target="_blank">part 3 of this series</a>, a formal tension parameter, T = 1-2s, was introduced.  All we noted about tension was that T=0 corresponds to s = 1/2.  At s=1/2, the Cardinal spline takes on the form of the more familiar Catmull-Rom spline.  The Catmull-Rom spline may, however, be derived independently from the notion of Cardinal splines as the blending of two parabolas [1].  The zero-tension Cardinal Spline happens to conforms to a well-known C-1 continuous spline.</p>
<p>What happens as the tension parameter is moved away from zero?  Can it reasonably be both positive and negative?  To better understand the effect of the tension parameter on the spline, the Cardinal-spline basis matrix is</p>
<pre>[ -s  2-s  s-2   s ]
[ 2s  s-3  3-2s -s ]
[ -s   0    s    0 ]
[  0   1    0    0 ]</pre>
<p>Given four arbitrary knots,</p>
<p>[P<sub>1</sub>, P<sub>2</sub>, P<sub>3</sub>, P<sub>4</sub>]</p>
<p>the following vector equation applies for an aribrary point P(t) on the curve from P<sub>2</sub> to P<sub>3</sub></p>
<p>P(t) = s(-t<sup>3</sup> + 2t<sup>2</sup> &#8211; t)P<sub>1</sub> + s(-t<sup>3</sup> + t<sup>2</sup>)P<sub>2</sub> + (2t<sup>3</sup> &#8211; 3t<sup>2</sup> + 1)P<sub>2</sub> + s(t<sup>3</sup> &#8211; 2t<sup>2</sup> + t)P<sub>3</sub> + (-2t<sup>3</sup> + 3t<sup>2</sup>)P<sub>3</sub> + s(t<sup>3</sup> &#8211; t<sup>2</sup>)P<sub>4</sub></p>
<p>We have already looked at T = 0, so consider T = 1, corresponding to s = 0.  The equation for P(t) reduces to</p>
<p>(2t<sup>3</sup> &#8211; 3t<sup>2</sup> + 1)P<sub>2</sub> + (-2t<sup>3</sup> + 3t<sup>2</sup>)P<sub>3</sub>, which can be simplified to</p>
<p>(3t<sup>2</sup> &#8211; 2t<sup>3</sup>)(P<sub>3</sub> &#8211; P<sub>2</sub>) + P<sub>2</sub>.  If u = 3t<sup>2</sup> &#8211; 2t<sup>3</sup>, then</p>
<p>P(t) = (1-u)P<sub>2</sub> + uP<sub>3</sub>, which is the parametric equation of a line from P<sub>2</sub> to P<sub>3</sub>.</p>
<p>While u does vary from 0 to 1, the primary curve parameter is t.  At t varies from 0 to 1, u is approximately sigmoid but very close to linear throughout its range.  So, we can say that as T approaches 1, the spline approaches a straight-line interpolation between knots.</p>
<p>The following screenshot shows a four-knot example with a black line connecting the knots and the spline drawn in blue with T=1.  The Degrafa Catmull-Rom spline is drawn in red, which corresponds to the Cardinal spline with zero tension.  This allows a comparison of the range of fits available in the tension range from zero to one.</p>
<div id="attachment_1759" class="wp-caption alignnone" style="width: 330px"><img class="size-full wp-image-1759" title="cardspline2" src="http://algorithmist.files.wordpress.com/2009/10/cardspline2.jpg?w=320&#038;h=237" alt="Tension Ranges in a Cardinal Spline" width="320" height="237" /><p class="wp-caption-text">Tension Ranges in a Cardinal Spline</p></div>
<p>The natural tension range is from zero to one.  Values outside this range are possible, although rarely practical.  These factors are discussed in the next section of this series.</p>
<p>References:</p>
<p>[1] Salomon, D. &#8220;Computer Graphics and Geometric Modeling&#8221;, Springer Verlag, NY, 1999.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/algorithmist.wordpress.com/1754/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/algorithmist.wordpress.com/1754/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/algorithmist.wordpress.com/1754/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/algorithmist.wordpress.com/1754/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/algorithmist.wordpress.com/1754/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/algorithmist.wordpress.com/1754/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/algorithmist.wordpress.com/1754/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/algorithmist.wordpress.com/1754/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/algorithmist.wordpress.com/1754/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/algorithmist.wordpress.com/1754/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=algorithmist.wordpress.com&blog=857842&post=1754&subd=algorithmist&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://algorithmist.wordpress.com/2009/10/06/cardinal-splines-part-4/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c3dbb3ae20bd7175acece4154c978a77?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">algorithmist</media:title>
		</media:content>

		<media:content url="http://algorithmist.files.wordpress.com/2009/10/cardspline2.jpg" medium="image">
			<media:title type="html">cardspline2</media:title>
		</media:content>
	</item>
		<item>
		<title>Cardinal Splines Part 3</title>
		<link>http://algorithmist.wordpress.com/2009/10/01/cardinal-splines-part-3/</link>
		<comments>http://algorithmist.wordpress.com/2009/10/01/cardinal-splines-part-3/#comments</comments>
		<pubDate>Thu, 01 Oct 2009 12:35:00 +0000</pubDate>
		<dc:creator>algorithmist</dc:creator>
				<category><![CDATA[Degrafa]]></category>
		<category><![CDATA[Math]]></category>
		<category><![CDATA[Cardinal Spline]]></category>
		<category><![CDATA[Geometry]]></category>
		<category><![CDATA[Splines]]></category>

		<guid isPermaLink="false">http://algorithmist.wordpress.com/?p=1742</guid>
		<description><![CDATA[Continuing from part 2 of this series, the tension in a Cardinal spline is controlled by the s-parameter.  Given a four-tuple of control points or knots,
[Pa, Pb, Pc, Pd]
cubic Hermite interpolation is applied with start-tangent s(Pc &#8211; Pa) and end-tangent s(Pd &#8211; Pb) .
Theoretically, s could vary from zero to positive infinity.  A [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=algorithmist.wordpress.com&blog=857842&post=1742&subd=algorithmist&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Continuing from <a href="http://algorithmist.wordpress.com/2009/09/28/cardinal-splines-part-2/" target="_blank">part 2 of this series</a>, the tension in a Cardinal spline is controlled by the s-parameter.  Given a four-tuple of control points or knots,</p>
<p>[P<sub>a</sub>, P<sub>b</sub>, P<sub>c</sub>, P<sub>d</sub>]</p>
<p>cubic Hermite interpolation is applied with start-tangent s(P<sub>c</sub> &#8211; P<sub>a</sub>) and end-tangent s(P<sub>d</sub> &#8211; P<sub>b</sub>) .</p>
<p>Theoretically, s could vary from zero to positive infinity.  A very long tangent vector, indicated by a large s-value causes the curve to follow the tangent very closely in and out of the join point.  A very small tangent vector, indicated by a small s-value, causes the curve to approach and leave the join point more like a straight line.</p>
<p>Intuitively, this is the opposite of how we expect tension to behave.  Larger tension should &#8216;pull&#8217; the curve closer to a straight-line interpolation of the knots, with exactly straight lines as a limiting case.  This gives rise to the convention of a formal tension parameter, T, that is inversely related to s.</p>
<p>The typical convention is to define s = (1-T)/2 or T = 1 &#8211; 2s.  Note that the zero-tension case corresponds to s = 1/2 or a relatively &#8216;loose&#8217; movement into and out of each join.  This special case corresponds to the Catmull-Rom spline.  For this reason, the C-R spline is sometimes called the zero-tension or neutral Cardinal spline.</p>
<p>The tension parameter will be discussed in more detail in subsequent posts in this series.  Tangent vectors are arbitrary at the initial and terminal knots, just as with the Catmull-Rom spline.  Fortunately, there are several methods for automatically assigning these tangents.  The C-R spline in Degrafa implements two methods; point duplication and point reflection.   Line segment reflection can be added as a third option.  It is also possible to allow designers to set these tangents interactively.</p>
<p>Local control via knot placement, tension control, and adjustment of initial/terminal tangent vectors provides artists with a variety of methods to design specific curves using Cardinal splines.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/algorithmist.wordpress.com/1742/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/algorithmist.wordpress.com/1742/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/algorithmist.wordpress.com/1742/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/algorithmist.wordpress.com/1742/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/algorithmist.wordpress.com/1742/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/algorithmist.wordpress.com/1742/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/algorithmist.wordpress.com/1742/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/algorithmist.wordpress.com/1742/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/algorithmist.wordpress.com/1742/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/algorithmist.wordpress.com/1742/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=algorithmist.wordpress.com&blog=857842&post=1742&subd=algorithmist&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://algorithmist.wordpress.com/2009/10/01/cardinal-splines-part-3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c3dbb3ae20bd7175acece4154c978a77?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">algorithmist</media:title>
		</media:content>
	</item>
		<item>
		<title>Cardinal Splines Part 2</title>
		<link>http://algorithmist.wordpress.com/2009/09/28/cardinal-splines-part-2/</link>
		<comments>http://algorithmist.wordpress.com/2009/09/28/cardinal-splines-part-2/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 13:07:36 +0000</pubDate>
		<dc:creator>algorithmist</dc:creator>
				<category><![CDATA[Degrafa]]></category>
		<category><![CDATA[Math]]></category>

		<guid isPermaLink="false">http://algorithmist.wordpress.com/?p=1725</guid>
		<description><![CDATA[Continuing from part 1 of this series,  consider a knot sequence, P0, P1, P2, &#8230; Pn-1 . The Cardinal spline fits a sequence of cubic polynomials to these knots, the first of which is between P0 and P1.  The second polynomial curve is between P1 and P2, and so forth.  Hermite interpolation is used [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=algorithmist.wordpress.com&blog=857842&post=1725&subd=algorithmist&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Continuing from <a href="http://algorithmist.wordpress.com/2009/09/24/cardinal-splines-part-1/" target="_blank">part 1 of this series</a>,  consider a knot sequence, P<sub>0</sub>, P<sub>1</sub>, P<sub>2</sub>, &#8230; P<sub>n-1</sub> . The Cardinal spline fits a sequence of cubic polynomials to these knots, the first of which is between P<sub>0</sub> and P<sub>1</sub>.  The second polynomial curve is between P<sub>1</sub> and P<sub>2</sub>, and so forth.  Hermite interpolation is used to compute the polynomial coefficients, so start- and end-tangents are required at each knot.</p>
<p>Cardinal splines specify the tangents at interior points based on the vector from previous point to subsequent point. Each tangent is parallel to this vector and some multiple of its length.  For example, the tangent direction at point P<sub>1</sub> is parallel to the vector P<sub>2</sub> &#8211; P<sub>0</sub>, or we could simply write something like T<sub>1</sub> = s(P<sub>2</sub> &#8211; P<sub>0</sub>) where s is a real number.</p>
<p>An astute reader immediately notices that this is very similar to the approach taken with the Catmull-Rom spline.  As it happens, the C-R spline is a special case of the cardinal spline with a fixed multiplier value.  It would be helpful to review <a href="http://www.algorithmist.net/media/catmullrom.pdf" target="_blank">this TechNote [PDF] on Catmull-Rom splines</a>.  The complete derivation of the Cardinal spline basis matrix is provided in the pages leading up to equation 5b.</p>
<p>The Cardinal spline provides an extra control parameter in terms of s.  Adjusting this parameter controls the degree to which the spline follows the tangent vector leading into and exiting from the join point.</p>
<p>One item not discussed in detail in the C-R TechNote is that that of locality in terms of knot movement.  In some splines, changing the location of a knot has a &#8216;ripple&#8217; effect through the entire spline.  With Cardinal splines, individual cubic polynomials are constructed with overlapping sets of four knots.  The sets are</p>
<p>[P<sub>0</sub>, P<sub>1</sub>, P<sub>2</sub>, P<sub>3</sub>]<br />
[P<sub>1</sub>, P<sub>2</sub>, P<sub>3</sub>, P<sub>4</sub>]<br />
[P<sub>2</sub>, P<sub>3</sub>, P<sub>4</sub>, P<sub>5</sub>]<br />
.<br />
.<br />
[P<sub>n-4</sub>, P<sub>n-3</sub>, P<sub>n-2</sub>, P<sub>n-1</sub>]</p>
<p>Denoting an arbitrary set by</p>
<p>[P<sub>a</sub>, P<sub>b</sub>, P<sub>c</sub>, P<sub>d</sub>]</p>
<p>Hermite interpolation is applied to points P<sub>b</sub> and P<sub>c</sub> with start tangent s(P<sub>c</sub> &#8211; P<sub>a</sub>) and s(P<sub>d</sub> &#8211; P<sub>b</sub>).</p>
<p>So, each knot participates in at most four spline segments.  This tends to localize the effect of moving any single knot.  Hermite interpolation is very efficient, so there is no system of equations to be solved to compute polynomial coefficients.  A price is paid, however, for this convenience and this is loss of second-derivative continuity.  A Cardinal spline is at best C-1 continuous.</p>
<p>The next part of this series looks at the s parameter in more detail.  While it is tempting to think of it directly as a tension parameter, it is related to tension.  It will be shown that the Catmull-Rom spline is a zero-tension or &#8216;neutral&#8217; Cardinal spline.  We will also discuss tangent directions at the initial and terminal knot as these are clearly arbitrary in the above analysis.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/algorithmist.wordpress.com/1725/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/algorithmist.wordpress.com/1725/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/algorithmist.wordpress.com/1725/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/algorithmist.wordpress.com/1725/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/algorithmist.wordpress.com/1725/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/algorithmist.wordpress.com/1725/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/algorithmist.wordpress.com/1725/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/algorithmist.wordpress.com/1725/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/algorithmist.wordpress.com/1725/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/algorithmist.wordpress.com/1725/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=algorithmist.wordpress.com&blog=857842&post=1725&subd=algorithmist&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://algorithmist.wordpress.com/2009/09/28/cardinal-splines-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c3dbb3ae20bd7175acece4154c978a77?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">algorithmist</media:title>
		</media:content>
	</item>
		<item>
		<title>Cardinal Splines Part 1</title>
		<link>http://algorithmist.wordpress.com/2009/09/24/cardinal-splines-part-1/</link>
		<comments>http://algorithmist.wordpress.com/2009/09/24/cardinal-splines-part-1/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 13:18:10 +0000</pubDate>
		<dc:creator>algorithmist</dc:creator>
				<category><![CDATA[Math]]></category>

		<guid isPermaLink="false">http://algorithmist.wordpress.com/?p=1713</guid>
		<description><![CDATA[When anyone hears the term &#8216;cardinal spline&#8217; for the first time, the most common question is why the name &#8216;cardinal?&#8217;  Yes, that was my first question way back in the day    As it happens, there is a subtle relation between the spline and the cardinal series [1].  I&#8217;ll leave it to interested readers [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=algorithmist.wordpress.com&blog=857842&post=1713&subd=algorithmist&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>When anyone hears the term &#8216;cardinal spline&#8217; for the first time, the most common question is why the name &#8216;cardinal?&#8217;  Yes, that was my first question way back in the day <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   As it happens, there is a subtle relation between the spline and the cardinal series [1].  I&#8217;ll leave it to interested readers to pursue the history and mathematics of the series as an aside.</p>
<p>I believe it was Schoenberg who said that the cardinal spline bridges the gap between linear splines and the cardinal series [2].  Again, I&#8217;ll leave the details to those who want to either read Schoenberg&#8217;s book or pursue the matter to whatever degree it is documented online.  In this series, we will be interested in how to construct cardinal splines and get them into Degrafa.</p>
<p>First, let&#8217;s back up and look at cubic Hermite interpolation.  Quadratic Hermite interpolation was discussed in the Quadratic Hermite Curve series (see the Degrafa page for links to the entire series).  This case involved interpolating two points with a quadratic polynomial.  The three degrees of freedom were resolved by forcing the curve to interpolate the two points and assigning a start tangent.  This selection inferred an end tangent as shown below.</p>
<div id="attachment_1714" class="wp-caption alignnone" style="width: 330px"><img class="size-full wp-image-1714" title="card1" src="http://algorithmist.files.wordpress.com/2009/09/card1.jpg?w=320&#038;h=164" alt="Start and End Tangents for a polynomial curve" width="320" height="164" /><p class="wp-caption-text">Start and End Tangents for a polynomial curve</p></div>
<p>Instead of selecting the start tangent, T0 and forcing the end tangent, T1, what if we allowed both tangents to be variable?  This introduces an extra degree of freedom, allowing a cubic curve to be constructed.  The cubic curve has more flexibility, but requires both T0 and T1 to be initially specified.</p>
<p>The natural question is why not develop a cubic Hermite spline?  We could, although it requires two initial parameter selections.  Most designers prefer to have a single element of control or have everything automatically done for them.  An alternative approach is to examine specialized cases of Hermite interpolation where the tangents are automatically chosen.</p>
<p>In part 2, we will look at one such specification and how this method produces a computationally efficient interpolant with an adjustable tension parameter for shape control.</p>
<p>References:</p>
<p>[1]  Higgins, J.R., &#8220;Five Short Stories About the Cardianal Series&#8221;, Bulletin of the American Mathematical Society, Vol. 12, No. 1, 1985.</p>
<p>[2] Schoenberg, I.J., &#8220;Cardinal Spline Interpolation&#8221;, The Mathematics Research Center, Univ. of Wisconsin-Madison, Regional Conference Series in Applied Mathematics, Capital City Press, 1993.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/algorithmist.wordpress.com/1713/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/algorithmist.wordpress.com/1713/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/algorithmist.wordpress.com/1713/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/algorithmist.wordpress.com/1713/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/algorithmist.wordpress.com/1713/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/algorithmist.wordpress.com/1713/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/algorithmist.wordpress.com/1713/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/algorithmist.wordpress.com/1713/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/algorithmist.wordpress.com/1713/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/algorithmist.wordpress.com/1713/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=algorithmist.wordpress.com&blog=857842&post=1713&subd=algorithmist&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://algorithmist.wordpress.com/2009/09/24/cardinal-splines-part-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c3dbb3ae20bd7175acece4154c978a77?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">algorithmist</media:title>
		</media:content>

		<media:content url="http://algorithmist.files.wordpress.com/2009/09/card1.jpg" medium="image">
			<media:title type="html">card1</media:title>
		</media:content>
	</item>
	</channel>
</rss>