How can I realize a surface between two circles plotted in 3D that not have the same centre?

8 views (last 30 days)
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

Accepted Answer

Mike Garrity
Mike Garrity on 23 Feb 2016
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))];
Roberta Palamà
Roberta Palamà on 24 Feb 2016
Hi Mike! Thank you for your answer!! I have tried to use your suggests and your code but I can't plot the surfaces. In attached there is my code and the errors that I have. Waiting for your answer, thank you very much !!!!!!!!!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by