how to determine the position of points which belong to a circle ?
古いコメントを表示
Hi how to determine the points of a circle (their x, y coordinates) if we knew the position of the center and the radius of the circle thanks!!!!
採用された回答
その他の回答 (1 件)
Image Analyst
2014 年 12 月 22 日
0 投票
6 件のコメント
jan
2014 年 12 月 23 日
Image Analyst
2014 年 12 月 23 日
The code I think you're looking for, which gives a list of x,y coordinates given a radius and center location is this:
xCenter = 12;
yCenter = 10;
theta = 0 : 0.01 : 2*pi;
radius = 5;
x = radius * cos(theta) + xCenter;
y = radius * sin(theta) + yCenter;
plot(x, y);
axis square;
xlim([0 20]);
ylim([0 20]);
grid on;
Change xCenter, yCenter, and radius value to whatever you need. If this answers your question, please mark as Accepted.
jan
2014 年 12 月 23 日
Image Analyst
2014 年 12 月 23 日
Give your actual MATLAB code - if it's different than this, I can add it to the FAQ as an alternate method.
Image Analyst
2014 年 12 月 23 日
Well the first way is a totally inefficient way of doing the first method of the FAQ. You can do it just once like the FAQ shows you instead of having a double for loop.
And your second half of your code is just the 4th block of code in the FAQ, just what I recommended to you but you said you didn't use . But you did - you just didn't realize it. Anyway, you don't need to do it both ways.
In your first code it seems like you're trying to get the perimeter pixels, while in the second code you're getting a solid circular disc. I think you should decide whether you want all the pixels in the circle, or just the perimeter pixels, and use the section of the FAQ that does whichever one you want. I would not use your code as-is.
カテゴリ
ヘルプ センター および File Exchange で Programming についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!