<?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/"
	>

<channel>
	<title>Electronic Space Nintendo &#187; Catmull-Rom</title>
	<atom:link href="http://www.doomsday.no/esn/tag/catmull-rom/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.doomsday.no/esn</link>
	<description>Video games, Weirdness, Adobe Flash, Android, Music, and TLDR</description>
	<lastBuildDate>Tue, 06 Dec 2011 00:47:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Spline normal facepalm</title>
		<link>http://www.doomsday.no/esn/2009/12/spline-normal-facepalm/</link>
		<comments>http://www.doomsday.no/esn/2009/12/spline-normal-facepalm/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 22:52:10 +0000</pubDate>
		<dc:creator>Andreas</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Catmull-Rom]]></category>
		<category><![CDATA[over-engineering]]></category>
		<category><![CDATA[splines]]></category>

		<guid isPermaLink="false">http://www.doomsday.no/esn/?p=780</guid>
		<description><![CDATA[I&#8217;ll be first in line to say I&#8217;m a slow learner, particularly in terms of math. I&#8217;m the sort of guy that will need facts banged home with a sledgehammer for at least half a year before they finally stick, and then 6 months more before they start mingling with the other facts and i [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll be first in line to say I&#8217;m a slow learner, particularly in terms of math. I&#8217;m the sort of guy that will need facts banged home with a sledgehammer for at least half a year before they finally stick, and then 6 months more before they start mingling with the other facts and i start being able to combine things into new things. I&#8217;m not embarrassed about that; it&#8217;s just my class of brain. I have no real education to speak of so everything I&#8217;ve learned has been on a per-project basis; experiences.</p>
<p>Splines is one of those concepts I&#8217;ve only recently started futzing about with. Bezier splines are neat for drawing, and i use Catmull-Rom splines for smoothly interpolating sequences of keyframes in animation. They&#8217;re neat, useful things. A toy I&#8217;m working on uses user-drawn Catmull-Rom splines as the basis of lofting and revolving 3d geometry. It&#8217;s not exactly NURBS, but it&#8217;s definitely in the same realm. It&#8217;s fascinating as hell. One of the earliest issues i ran into was getting the normal of a given point on a spline. And this is where it gets retarded, and i start over-engineering.</p>
<p>Instead of looking at the bigger picture, i immediately start looking for one-stop solutions for spline normals. After banging my head into that for a while, i realize a spline tangent is a more common goal, and i start banging my head into that one as well. The lesson here is that you don&#8217;t need one-stop solutions, and you don&#8217;t always have to use the smartest stuff if what you do winds up working. Turns out the easiest and most practical way to get a spline normal on a catmull-rom spline segment is to do the following:</p>
<ol>
<li>Sample the point on the spline you want a normal for (p1)</li>
<li>Sample another point (p2) on the spline slightly further along; for instance if p1 is at 0.5, sample p2 at 0.51</li>
<li>Subtract p2 from p1: Bam, you have a unit vector (v) parallel to the direction of the spline at p1</li>
<li>Get the normal to v by swapping and inverting its components.</li>
</ol>
<p>Since you&#8217;re sampling *along* the spline, the normal won&#8217;t ever flip.</p>
<p>It&#8217;s such an epic facepalm moment. Why did i think about it so hard? When you take a couple steps back and look at the problem &#8220;physically&#8221;, it&#8217;s dreamily clear! I&#8217;m sure there are &#8220;smarter&#8221; ways to get this information, but aside from the double spline sample (which is just a bunch of multiplications anyway) the rest of it is lightweight enough to be negligible. Unless you&#8217;re doing this a shit ton of times for a lot of geometry, the approach i outline works just fine, even for real-time purposes. In my naive fanciful mind, the &#8220;proper&#8221; solution is this overwrought slow thing that takes longer to execute. That might be complete bull, but hey <img src='http://www.doomsday.no/esn/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>I Googled this problem and found nothing this straightforward, so i hope it&#8217;ll help someone else too.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.doomsday.no/esn/2009/12/spline-normal-facepalm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

