how to find mean point in a number of points in a circle
3 次查看(过去 30 天)
显示 更早的评论
I have a circle with a few number of random points inside it. I divided the circle to four parts that separated the internal random points to each section of four. I want to find the mean point in each section and draw a line from center to the mean point of each section. This is my code until now:
function [randPoints]=hd04circle(xCenter,yCenter,r,n)
drawCircle(xCenter,yCenter,r); hold on
drawLine(xCenter,yCenter,r);
%continuesPoints(xCenter,yCenter,r,n);
randPoints=pointsInCircle(xCenter,yCenter,r,n); hold on
%findMediumPoint(pointsArr,r,n);
%for i=1:n
% drawCircle(randPoints(i,1),randPoints(i,2),r); hold on
%end
%-----------------------------
function drawCircle(xC,yC,r)
degree=0:0.01:2*pi;
yp=r*sin(degree);
xp=r*cos(degree);
plot(xC+xp,yC+yp); hold on
%-----------------------------
function [randx,randy]=randNoGenerator(xC,yC,rc)
a=2*pi*rand
r=sqrt(rand)
randx=(rc*r)*cos(a)+xC
randy=(rc*r)*sin(a)+yC
%-----------------------------
function continuesPoints(xCenter,yCenter,r,n)
while true
for i=1:n
[x,y]=randNoGenerator(xCenter,yCenter,r);
plot(x,y,'o'); hold all
%drawCircle(x,y,r); hold on
end
pause(3);
end
%-----------------------------
function [randPoints]=pointsInCircle(xCenter,yCenter,r,n)
for i=1:n
[x,y]=randNoGenerator(xCenter,yCenter,r);
plot(x,y,'o'); hold all
randPoints(i,1)=x;
randPoints(i,2)=y;
end
%-----------------------------
function drawLine(xC,yC,r)
plot([xC-(2*r),xC+(2*r)],[yC,yC]); hold on
plot([xC,xC],[yC-(2*r),yC+(2*r)]); hold on
%-----------------------------
2 个评论
Image Analyst
2015-7-8
What is your definition of the "medium" point. Do you mean the point at the center of the circle?
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Subplots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!