Suppose I have a 3D concave surface defined in an MxN mesh r,tht,z where:
tht = repmat(linspace(0, 2*pi, N), M, 1) is MxN;
r is monotonically increasing MxN
z is monotonically increasing MxN
I need to fit a smooth periodic spline to this data where the innermost r for
each tht is at the fixed specified value r(1, :) > 0
Sample data can be generated by:
N = 10;
M = 5;
tht = repmat(linspace(0, 2*pi, N), M, 1); % tht is uniform
r = rand(M, N);
r(1, :) = 1; % Fix inner circle at r==1
r(:, end) = r(:, 1); % Ensure r at 0 deg == r at 360 deg
r = cumsum(r, 1); % Ensure r is monotonically increasing
[x,y] = pol2cart(tht, r);
rmax = max(r(:)) * 1.1;
z = sqrt(rmax^2 - x.^2 - y.^2);
figurewsd
surf(x,y,z)
axis equal
grid on
I suspect that I need to use csape in the curve fitting toolbox to fit this
periodic surface with this end condition, however I can't quite understand the
documentation and examples.
From the examples provided, I suspect that I need to do something in the form
sph = csape({x,y},v,{'clamped','periodic'});
However, the form of x, y, and z in the provided example confused me.
Does anyone have a suggestion how I could use this (or another) function
to fit my defined surface?
Added complications:
1. Would this change if tht was slightly different than uniform for each r?
2. What if I wanted to clamp the fit at r(end, :), as well?
Thanks so much for any advice.