Get coordinates points inside a 3-D circle in MATLAB

4 次查看(过去 30 天)
Hi there,
I am trying to generate a 3-D circle to get the points inside it and the border. I already have a function to draw and get border points (Christian Reinbacher (2022). Plot Circle in 3D (https://www.mathworks.com/matlabcentral/fileexchange/26588-plot-circle-in-3d), MATLAB Central File Exchange. Retrieved July 31, 2022.) but not sure how to get points inside it. Will be appreciated if someone could help.
normal=[-3.5556 -0.2222 1.0000];
center=[138 146 219];
radius=3;
function plotCircle3D(center,normal,radius)
%Inputs:
% center ---> Centre point of circle
% normal ---> normal vector
% radius ---> Radius of circle
theta =0:0.01:2*pi;
v=null(normal);
points=repmat(center',1,size(theta,2))+radius*(v(:,1)*cos(theta)+v(:,2)*sin(theta));
p = fill3(points(1,:),points(2,:),points(3,:),'r-');
view(3);
end
With this function, I can get border points but not inside points. I know there are infinite points inside, but if I can get many of them, it would be great.
Thanks in advance,
Ali

回答(1 个)

Chunru
Chunru 2022-8-1
normal=[-3.5556 -0.2222 1.0000];
center=[138 146 219];
radius=3;
plotCircle3D(center,normal,radius);
hold on
point = plotPointOnCircle3D(center,normal,2,pi/3)
point = 3×1
138.4080 147.0125 220.6758
plot3(point(1), point(2), point(3), 'bo')
function plotCircle3D(center,normal,radius)
%Inputs:
% center ---> Centre point of circle
% normal ---> normal vector
% radius ---> Radius of circle
theta =0:0.01:2*pi;
v=null(normal);
points=repmat(center',1,size(theta,2))+radius*(v(:,1)*cos(theta)+v(:,2)*sin(theta));
p = fill3(points(1,:),points(2,:),points(3,:),'r-', 'FaceAlpha', 0.5);
view(3);
end
function point = plotPointOnCircle3D(center,normal,radius,theta)
%Inputs:
% center ---> Centre point of circle
% normal ---> normal vector
% radius ---> Radius of circle
v=null(normal);
point=repmat(center',1,size(theta,2))+radius*(v(:,1)*cos(theta)+v(:,2)*sin(theta));
end

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by