{"id":481,"date":"2016-06-22T07:22:32","date_gmt":"2016-06-21T23:22:32","guid":{"rendered":"http:\/\/www.cgdev.net\/blog\/?p=481"},"modified":"2021-12-20T02:14:49","modified_gmt":"2021-12-19T18:14:49","slug":"cardinal-spline-and-catmull-rom-spline","status":"publish","type":"post","link":"https:\/\/www.cgdev.net\/blog\/481.html","title":{"rendered":"Catmull-Rom Spline and Cardinal Spline Basis Functions"},"content":{"rendered":"<p>A Cardinal spline( sometimes called Canonical spline )consists of a sequence of curves. Consider a single Cardinal segment:<\/p>\n<p>\\[<br \/>\nF(u) = C_0 + uC_1 + u^2C_2 + u^3C_3<br \/>\n\\]<\/p>\n<p>Suppose it starts at \\(F(0) = P_i\\) and ends at \\(F(1)=P_{i+1}\\). We don&#8217;t need to provide the tangent for each point because it can be calculated from two ajacent control points. The constrant equations are very similar to the Hermite spline:<\/p>\n<p>\\begin{align}<br \/>\nP_i &amp;= F(0)\u00a0 = C_0 \\\\<br \/>\nP_{i+1} &amp;= F(1)\u00a0 =\u00a0 C_0 + C_1 + C_2 + C_3 \\\\<br \/>\nP&#8217;_i &amp;= k(P_{i+1} &#8211; P_{i-1}) = F'(0) = C_1 \\\\<br \/>\nP&#8217;_{i+1} &amp;= k(P_{i+2} &#8211; P_i) = F'(1) = C_1 + 2C_2 + 3C_3<br \/>\n\\end{align}<\/p>\n<p>The parameter k is a tension parameter that must be in the interval [0,1]. Now, \\(C\\) can be represented as:<\/p>\n<p>\\begin{align}<br \/>\nC_0 &amp;= P_i \\\\<br \/>\nC_1 &amp;= -kP_{i-1} + kP_{i+1} \\\\<br \/>\nC_2 &amp;= 2kP_{i-1} + (k-3)P_i + (3-2k)P_{i+1} &#8211; kP_{i+2} \\\\<br \/>\nC_3 &amp;= -kP_{i-1} + (2-k)P_i + (k-2)P_{i+1} + kP_{i+2}<br \/>\n\\end{align}<\/p>\n<p>Then we get the Cardinal matrix \\(A\\) and \\(C\\) can be represented as:<\/p>\n<p>\\begin{align}<br \/>\n\\begin{pmatrix} C_0 \\\\ C_1 \\\\ C_2 \\\\ C_3 \\end{pmatrix} =<br \/>\n\\begin{pmatrix}<br \/>\n0 &amp; 1 &amp; 0 &amp; 0 \\\\<br \/>\n-k &amp; 0 &amp; k &amp; 0 \\\\<br \/>\n2k &amp; k-3 &amp; 3-2k &amp; -k \\\\<br \/>\n-k &amp; 2-k &amp; k-2 &amp; k<br \/>\n\\end{pmatrix}<br \/>\n\\begin{pmatrix} P_{i-1} \\\\ P_i \\\\ P_{i+1} \\\\ P_{i+2} \\end{pmatrix}<br \/>\n\\end{align}<\/p>\n<p>Now we can derive the Cardinal basis:<\/p>\n<p>\\[<br \/>\n\\eta = \\left \\{ -ku + 2ku^2 &#8211; ku^3, ~~~\u00a0 1 + (k-3)u^2 + (2-k)u^3, ~~~\u00a0 ku + (3-2k)u^2 + (k-2)u^3,~~~\u00a0 -ku^2 + ku^3 \\right \\}<br \/>\n\\]<\/p>\n<p>Catmull-Rom spline is a special case of a Cardinal spline. Choosing tension parameter \\(k = \\frac 1 2\\) yields the basis:<\/p>\n<p>\\[<br \/>\n\\eta = \\left \\{ -\\frac 1 2 u + u^2 &#8211; \\frac 1 2 u^3, ~~~\u00a0 1 -\\frac 5 2 u^2 + \\frac 3 2 u^3, ~~~\u00a0 \\frac 1 2 u + 2u^2 -\\frac 3 2 u^3,~~~\u00a0 -\\frac 1 2 u^2 + \\frac 1 2 u^3 \\right \\}<br \/>\n\\]<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A Cardinal spline( sometimes called Canonical spline )consists of a sequence of curves. Consider a single Cardinal segment: \\[ F(u) = C_0 + uC_1 + u^2C_2 + u^3C_3 \\] Suppose it starts at \\(F(0) = P_i\\) and ends at \\(F(1)=P_{i+1}\\). We don&#8217;t need to provide the tangent for each point because it can be calculated [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-481","post","type-post","status-publish","format-standard","hentry","category-graphics"],"_links":{"self":[{"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/posts\/481","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/comments?post=481"}],"version-history":[{"count":0,"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/posts\/481\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/media?parent=481"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/categories?post=481"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/tags?post=481"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}