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

5 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Mike Garrity
Mike Garrity el 23 de Feb. de 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))];
  4 comentarios
Mike Garrity
Mike Garrity el 24 de Feb. de 2016
Editada: Mike Garrity el 24 de Feb. de 2016
Ah, you're not just connecting two circles, you're trying to sweep a circle along a path. That's a bit harder!
I covered the basic approach on the MATLAB Graphics blog. Here's the first part, which covers the basic math. And here's the second part, which uses that to sweep a 2D shape along the curve. I only did a square, but to do a circle you just need the cos,sin part from above. These blog posts are really about how you get come up with the three orthonormal vectors at the center of each circle. These are called a Frenet frame.
I will point out that there is another hairy case waiting if you ever have the radius of curvature of your path become smaller than the radius of your circles. Hopefully you won't have to worry about that.
Roberta Palamà
Roberta Palamà el 24 de Feb. de 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 !!!!!!!!!

Iniciar sesión para comentar.

Más respuestas (0)


Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.


Community Treasure Hunt

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

Start Hunting!

Translated by