MATLAB: How to realize a surface between two circles plotted in 3D that not have the same centre

3d model3d plots

Hi!! I have to realize a surface between two circles plotted in 3D that not have the same center. I have to plot a sort of trucated cone. I have tried to use the Matlab functions called cylinder and then surf but to no avail. Can someone help me, please? This is the last step of my theses so it's very important for me! Best regards. Roberta

Best Answer

There isn't a built-in for this. There's one on the File Exchange that's close to what you want. It's also relatively easy to do by hand:
% Define my 2 circles
rng default
center1 = randn(1,3);
radius1 = .25;
center2 = randn(1,3);
radius2 = 1.25;
% Create 3 orthonormal vectors. The first goes from center1 to center2.
v1 = center2 - center1;
v1 = v1 / norm(v1);
v2 = cross(v1+randn(1,3),v1);
v2 = v2 / norm(v2);
v3 = cross(v1,v2);
v3 = v3 / norm(v3);
% Create 2x32 arrays of points.
ang = linspace(0,2*pi,32);
x = [center1(1) + radius1*(v2(1)*cos(ang) + v3(1)*sin(ang)); ...
center2(1) + radius2*(v2(1)*cos(ang) + v3(1)*sin(ang))];
y = [center1(2) + radius1*(v2(2)*cos(ang) + v3(2)*sin(ang)); ...
center2(2) + radius2*(v2(2)*cos(ang) + v3(2)*sin(ang))];
z = [center1(3) + radius1*(v2(3)*cos(ang) + v3(3)*sin(ang)); ...
center2(3) + radius2*(v2(3)*cos(ang) + v3(3)*sin(ang))];
surf(x,y,z,'FaceColor','yellow')
Related Question