How to plot specified semi-circle, rectangle ?
Mostrar comentarios más antiguos
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
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Signal Analysis en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





