Fast Cardinal and Catmull-Rom Spline Interpolation

版本 1.0.3 (1.8 KB) 作者: Moreno, M.
Optimal generation of cardinal splines of arbitrary dimensions, comprising Catmull-Rom (centripetal) types.
43.0 次下载
更新时间 2022/6/8

查看许可证

Syntax
y = cspl(x)
y = cspl(x,n)
y = cspl(x,n,k)
Description
y = cspl(x,n,k) Returns a cardinal spline 'y' from its nodes 'x' and resolution 'n'. The parameter 'k' can optionally specify the tension of the curve, which is set to zero by default (centripetal). As per:
[1] Catmull, E. & Rom, R. 'A class of local interpolating splines'. CAGD, R. E. Barnhill and R. F. Reisenfeld, Eds. Academic Press. New York, 1974, pp. 317–326.
[2] Twigg, C. 'Catmull-Rom Splines' CMU School of Computer Science. Online Resource, 2003.
The function operates column-wise along the dimensions of 'x' and it is optimised for speed.
See also: bspl
Examples
% Generate random nodes
x = rand(4,2);
% Interpolate different splines
a = cspl(x);
b = cspl(x,[],0.25);
c = cspl(x,100,0.5);
% Plot curves
figure, hold on
plot(a(:,1), a(:,2))
plot(b(:,1), b(:,2))
plot(c(:,1), c(:,2))
plot(x(:,1), x(:,2), 'o')
legend 'Centripetal (0)' 'Cardinal (0.25)' ...
'Cardinal (0.50)' 'Random Nodes'
% Interpolate in N-dimensions
figure
plot(cspl(rand(4),100),'.');
legend 'dim 1' 'dim 2' 'dim 3' 'dim 4'

引用格式

Moreno, M. (2024). Fast Cardinal and Catmull-Rom Spline Interpolation (https://www.mathworks.com/matlabcentral/fileexchange/112810-fast-cardinal-and-catmull-rom-spline-interpolation), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2022a
兼容任何版本
平台兼容性
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.0.3

The default function call y = cspl(x) produces curves with at least 100 points of resolution.

1.0.2

Faster processing of duplicates by initialising 'y' with the last 'x' value, and using a knot vector with open interval [0,1). Change of interpolation method from 'makima' to 'spline' if a resolution is queried. Removed minimum interval resolution.

1.0.1

Removal of duplicate values and interpolation to query resolution if 'n' is not parsed. Enhancement of the function description text. As a result, the function is faster when resolution values are not parsed, and it is exempt of duplicate values.

1.0.0