# 2D Circle 3D Plot.

225 views (last 30 days)
reza on 31 Dec 2013
Hello, How can i draw a circle in a 3d plot? thanks,

Azzi Abdelmalek on 31 Dec 2013
Edited: Azzi Abdelmalek on 31 Dec 2013
r=1
teta=-pi:0.01:pi
x=r*cos(teta);
y=r*sin(teta)
plot3(x,y,zeros(1,numel(x)))
Tong Zhao on 13 Sep 2021
Edited: Tong Zhao on 13 Sep 2021
The next question would be, how to draw a filled circle in 3D, parallel to say, x-y plane.

Image Analyst on 13 Sep 2021
Try this:
ellipsoid(0,-0.5,0.5,6,3.25,0.01)
zlim([0,1]); %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.
%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) );
plot3(x,y,z,color)
% then call the function as
pos = rand(3,1);rad = 1;R = eye(3);
hold on
axis equal