How to plot specified semi-circle, rectangle ?
이전 댓글 표시
Hi all
I have 2 points, and need to plot semi-circle, rectangle as folowing picture.

semi-circle need to perpendiculars with slope of 2 points line.
In Case A - simple case which Ay = By. I created code as:
A = [2,2];
B = [5,2];
plot([A(1) B(1)],[A(2) B(2)],'-og');
hold on;
x_centerCircle = A(1);
y_centerCircle = A(2);
r=1; % Radius 1m
theta = linspace(pi/2, 3*pi/2, 100);
xCirc = r * cos(theta) + x_centerCircle;
yCirc = r * sin(theta) + y_centerCircle;
plot(xCirc, yCirc, 'r');
plot([xCirc(1), xCirc(end)], [yCirc(1), yCirc(end)], 'r');
rectangle('Position',[x_centerCircle x_centerCircle-0.075 5 0.15], 'EdgeColor', 'r');
grid on;
xlim([0 8]);
ylim([0 4]);
But when line AB does not parallel with Ox (Case B), becomes more difficult.
Do anyone show me how to plot for all cases?
Thank you so much
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Signal Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





