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!





