Azzera filtri
Azzera filtri

how to find mean point in a number of points in a circle

2 visualizzazioni (ultimi 30 giorni)
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 Commenti
Image Analyst
Image Analyst il 8 Lug 2015
What is your definition of the "medium" point. Do you mean the point at the center of the circle?
H D
H D il 8 Lug 2015
Running the code it is a circle divided to four sections. in each section there are a few number of random points. I need to draw a line from center to the point which is in center of the other points in the section. I think I made some spelling error. sorry

Accedi per commentare.

Risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by