how to find mean point in a number of points in a circle
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Image Analyst
le 8 Juil 2015
What is your definition of the "medium" point. Do you mean the point at the center of the circle?
Réponses (0)
Voir également
Catégories
En savoir plus sur Subplots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!