Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 31 de Dic. de 2013
Editada: Azzi Abdelmalek el 31 de Dic. de 2013

6 votos

r=1
teta=-pi:0.01:pi
x=r*cos(teta);
y=r*sin(teta)
plot3(x,y,zeros(1,numel(x)))

6 comentarios

reza
reza el 1 de En. de 2014
thanks a lot. know i can create a 3d cone using 2d circles.
Beril Sirmacek
Beril Sirmacek el 25 de En. de 2018
thanks :)
Anand S
Anand S el 31 de Jul. de 2020
how can i vary the location of circle in the z axis
Image Analyst
Image Analyst el 31 de Jul. de 2020
% Define circle parameters:
radius = 1;
xCenter = 1.5;
yCenter = 4;
zCenter = 3;
% Make an array for all the angles:
theta = linspace(0, 2 * pi, 2000);
% Create the x and y locations at each angle:
x = radius * cos(theta) + xCenter;
y = radius * sin(theta) + yCenter;
% Need to make a z value for every (x,y) pair:
z = zeros(1, numel(x)) + zCenter;
% Do the plot:
% First plot the center:
plot3(xCenter, yCenter, zCenter, 'r*', 'LineWidth', 2, 'MarkerSize', 15);
hold on; % Don't let circle blow away our center.
% Next plot the circle:
plot3(x, y, z, 'b-', 'LineWidth', 2);
grid on;
axis('square');
xlabel('x', 'FontSize', 20);
ylabel('y', 'FontSize', 20);
zlabel('z', 'FontSize', 20);
Priodyuti Pradhan
Priodyuti Pradhan el 2 de Nov. de 2020
Thanks for sharing!
Tong Zhao
Tong Zhao el 13 de Sept. de 2021
Editada: Tong Zhao el 13 de Sept. de 2021
The next question would be, how to draw a filled circle in 3D, parallel to say, x-y plane.
OK. I found an answer using patch at this thread.

Iniciar sesión para comentar.

Más respuestas (2)

Image Analyst
Image Analyst el 13 de Sept. de 2021

0 votos

Try this:
ellipsoid(0,-0.5,0.5,6,3.25,0.01)
zlim([0,1]);
Aaron T. Becker's Robot Swarm Lab
Aaron T. Becker's Robot Swarm Lab el 14 de Mzo. de 2022

0 votos

%A circle in 3D is parameterized by six numbers: two for the orientation of its unit normal vector, one for the radius, and three for the circle center.
function drawCircle(rad,pos,n,color)
%https://demonstrations.wolfram.com/ParametricEquationOfACircleIn3D/
%draws a 3D circle at position pos with radius rad, normal to the
%circle n, and color color.
phi = atan2(n(2),n(1)); %azimuth angle, in [-pi, pi]
theta = atan2(sqrt(n(1)^2 + n(2)^2) ,n(3));% zenith angle, in [0,pi]
t = 0:pi/32:2*pi;
x = pos(1)- rad*( cos(t)*sin(phi) + sin(t)*cos(theta)*cos(phi) );
y = pos(2)+ rad*( cos(t)*cos(phi) - sin(t)*cos(theta)*sin(phi) );
z = pos(3)+ rad*sin(t)*sin(theta);
plot3(x,y,z,color)
% then call the function as
pos = rand(3,1);rad = 1;R = eye(3);
drawCircle(rad,pos,R(:,1),'r')
hold on
drawCircle(rad,pos,R(:,2),'g')
drawCircle(rad,pos,R(:,3),'b')
axis equal

Categorías

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by