Interpolate Helix in 3d
Show older comments
I have three helices with 39 data points for each helix:
t=linspace(0,8.6*pi,39);
plot3(35*cos(t)+35,35*sin(t)+35,t,'LineWidth',3);
hold on;
plot3(25*cos(t)+35,25*sin(t)+35,t,'LineWidth',3);
plot3(15*cos(t)+35,15*sin(t)+35,t,'LineWidth',3);
hold off;
I am wondering how I could interpolate the area between the helices in the x,y,z direction? Thanks!

Answers (1)
John D'Errico
on 14 Mar 2017
Edited: John D'Errico
on 15 Mar 2017
t=linspace(0,8.6*pi,39);
x = 35*cos(t)+35;
y = 35*sin(t)+35;
xyzi = interparc(1000,x,y,t,'spline');
plot3(x,y,t,'ro')
hold on
plot3(xyzi(:,1),xyzi(:,2),xyzi(:,3),'-b')
box on
grid on

But re-reading your question, you asked to interpolate the area BETWEEN the helices.
Are you asking how to make the three curves into a plottable surface, connecting them together? This is quite doable, but I won't do so without affirmation from you as to my guess.
6 Comments
Robert Wu
on 15 Mar 2017
John D'Errico
on 15 Mar 2017
Edited: John D'Errico
on 15 Mar 2017
Good, in one sense. At least I did not waste time on a mis-guess. :)
So you have some general helix, not a nice, easily defined, circular, cylindrical helix. It is defined only by a set of ordered triplets in 3-d. And now you want to interpolate up along the axis of the helix. I suppose, just to make things even worse, you won't even be willing to assume the axis is parallel to the z-axis?
The point is, if you were willing to parameterize the domain in cylindrical coordinates, then you could write the helix as an ordered set of triplets (r,theta,z). Now, your goal would be to create the surface r(theta,z). This would be doable. If it turned out that the cylinder axis were not parallel to the z-axis, then I would find the axis, and do a rotation of the coordinate space so that is now true. At least that part is totally simple.
So, I might start like this:
z = t;
xbar = mean(x);
ybar = mean(y);
theta = atan2(y-ybar,x-xbar);
r = sqrt((x-xbar).^2 + (y-ybar).^2);
plot3(theta,z,r,'o')
grid on
box on
view(-7,18)

I'm not sure you can see that as obviously a surface, if you rotate the figure around a bit, you will see it as such.
[rgrid,thetagrid,zgrid] = gridfit(theta,z,r,linspace(-pi,pi,100),linspace(min(z),max(z),100));
figure
plot3(theta,z,r,'ro')
hold on
surf(thetagrid,zgrid,rgrid)
view(-7,18)
box on
grid on
xlabel theta
ylabel z
zlabel r

Ok, this is better. We have a surface, that in theory could be converted back into the original coordinate system. But for one small problem, that when I built the gridded surface, I was unable to explicitly put in the information that it was periodic in theta.
So you can see there is some crap happening at the boundary where theta transitions from -pi to pi.
Gridfit is unable to handle a periodic boundary condition like that, and as you can see, the edge in that region got a bit ragged, since gridfit thinks it is forced to extrapolate.
Lets recover the original coordinate system.
xgrid = xbar + rgrid.*cos(thetagrid);
ygrid = ybar + rgrid.*sin(thetagrid);
surf(xgrid,ygrid,zgrid,'edgecolor','none')
hold on
plot3(x,y,z,'ro')
view(-171,78)
box on
grid on

It is pretty good, except that the periodic boundary fails periodicity. I've rotated the view to show that problem.
If that were not a problem, then I would tell you to simply download gridfit from the File Exchange and use it as is.
It is a start at least. :) That gives you a surface.
Then your next comment was you wanted to next interpolate between these surfaces. That would create what is essentially a 3-d volume, a cylinder with a thick wall. I'm not sure what you mean by interpolating there.
Robert Wu
on 16 Mar 2017
John D'Errico
on 16 Mar 2017
I don't know what you have shown me there. You need to be careful in what variables you treat as the dependent and independent variables. Perhaps you might attach the actual data that you have.
The -pi/pi boundary will be an issue here, as gridfit would need to be modified to solve your problem. It would almost be easier to write a hacked (and very simple version) that did have periodic boundary conditions in one variable.
Anyway, there are other solutions one might look at. For example, given all three curves, generate a 3-d delaunay tessellation. Of course, that will include the volume internal to the central helix. Now, delete any tetrahedra that cross that internal region. The result will be a tessellation of the annular volume in question. The only issue would be how to delete the stuff in the middle. That would be doable though, and it completely eliminates the periodic boundary problem.
Robert Wu
on 16 Mar 2017
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
