Created
April 21, 2011 16:55
-
-
Save jcchurch/934980 to your computer and use it in GitHub Desktop.
This function computes the 3D spline interpolation of a 3D dataset. I did not write this code.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function newCurve = spline3d(curve, dt) | |
% interpote a 3d curve using spline | |
% path 3*x | |
% newPath 3*x | |
x = curve(1, :); | |
y = curve(2, :); | |
z = curve(3, :); | |
t = cumsum([0;sqrt(diff(x(:)).^2 + diff(y(:)).^2 + diff(z(:)).^2)]); | |
sx = spline(t,x); | |
sy = spline(t,y); | |
sz = spline(t,z); | |
tt = t(1):dt:t(end); | |
xp = ppval(sx, tt); | |
yp = ppval(sy, tt); | |
zp = ppval(sz, tt); | |
newCurve = [xp; yp; zp]; | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment