Skip to content

Instantly share code, notes, and snippets.

Created June 23, 2014 20:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/0eedb67914f554ee9cb5 to your computer and use it in GitHub Desktop.
Save anonymous/0eedb67914f554ee9cb5 to your computer and use it in GitHub Desktop.
(* Barry-Goldman recursive algorithm for Catmull-Rom splines *)
L[i_, j_, \[Tau]_] := (t[j] - \[Tau])/(t[j] - t[i])
P[i] + (\[Tau] - t[i])/(t[j] - t[i]) P[j]
L[i_, j_,
k_, \[Tau]_] := (t[k] - \[Tau])/(t[k] - t[i])
L[i, j, \[Tau]] + (\[Tau] - t[i])/(t[k] - t[i]) L[j, k, \[Tau]]
S[i_, j_, \[Tau]_] := (t[j] - \[Tau])/(t[j] - t[i])
L[i - 1, i, j, \[Tau]] + (\[Tau] - t[i])/(t[j] - t[i])
L[j - 1, j, j + 1, \[Tau]]
S[1, 2, \[Tau]] /. {\[Tau] -> t[1]} // FullSimplify
S[1, 2, \[Tau]] /. {\[Tau] -> t[2]} // FullSimplify
D[S[1, 2, \[Tau]], \[Tau]] /. {\[Tau] -> t[1]} // FullSimplify
D[S[1, 2, \[Tau]], \[Tau]] /. {\[Tau] -> t[2]} // FullSimplify
P[1]
P[2]
(P[0] - P[1])/(t[0] - t[1]) + (-P[0] + P[2])/(t[0] - t[2]) + (
P[1] - P[2])/(t[1] - t[2])
(P[1] - P[2])/(t[1] - t[2]) + (-P[1] + P[3])/(t[1] - t[3]) + (
P[2] - P[3])/(t[2] - t[3])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment