how to make rectangle in circle?
조회 수: 6 (최근 30일)
이전 댓글 표시
I want to make rectangles in circle.
I know the radius, rectangle's width and length.
please let me know how to do this
thanks
채택된 답변
Matt J
2022년 11월 19일
편집: Matt J
2022년 11월 19일
[X,Y]=ndgrid(-10:10);
r=arrayfun( @(x,y) nsidedpoly(4,'Center',[x,y],'Radius',1/sqrt(2)) , X(:),Y(:));
c=intersect(nsidedpoly(1000,'Radius',5), scale(r,[1,1.5]));
plot(c,'FaceColor','none')
댓글 수: 4
Matt J
2022년 11월 20일
width=1;
length=1.3;
circleRadius=10;
[X,Y]=ndgrid(-circleRadius:width:circleRadius+width);
r=arrayfun( @(x,y) nsidedpoly(4,'Center',[x,y],'Radius',width/sqrt(2)) , X(:),Y(:));
c=intersect(nsidedpoly(1000,'Radius',circleRadius), scale(r,[1,length/width]));
c=translate(c,ARP_lon,ARP_lat);
plot(c,'FaceColor','none'); axis equal
추가 답변 (1개)
Image Analyst
2022년 11월 19일
See the FAQ:
Then plot it with plot and then for each x and y value you want find the end points of a line segment and use line() or plot() to draw the line from one side of the circle to the other. It's easy but if you really can't figure it out then write back.
댓글 수: 3
Image Analyst
2022년 11월 20일
You do not ned to know the crossing/intersection coordinates of the vertical and horizontal lines inside the circle. All you need to know for the horizontal lines is the y value and the two points on the circle closest to that y value. Similar for the lines in the other direction. But it looks like @Matt J suggested a different approach and you accepted that so I won't proceed with my approach.
참고 항목
카테고리
Help Center 및 File Exchange에서 Geographic Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!