Drawing an arc on the end of a straight line

4 visualizaciones (últimos 30 días)
Chris cjsholmes@hotmail.com
Chris cjsholmes@hotmail.com el 9 de Mayo de 2015
Comentada: Star Strider el 25 de Abr. de 2020
I am trying to find out a way to plot an arc on the end of a line in Matlab.
For instance:
I have an array that runs from -1 to +1, and I wish for the central section (-0.7:0.7) to be 0, and then at each side a quarter circle of radius 0.3 going up into the +y direction. (See image if my poor description of the geometry is doing no good).
I cannot figure out the equation of a line to do the curves, and I can't seem to translate anything on the internet to this problem, where I need to find the equation of that line as a function of x, where the x-axis runs from 1:20, and each curve section is from 1:30 and 70:200 respectively.
Any help is much appreciated, I'm sure this can't be that hard, but I'm out of ideas.

Respuestas (1)

Star Strider
Star Strider el 9 de Mayo de 2015
Recalling basic geometry, for an angle vector going from 0 to 2*pi, the equation for a complete circle with radius ‘r’ is given as:
angle = linspace(0,2*pi);
r = 1;
x = r*cos(angle);
y = r*sin(angle);
figure(1)
plot(x, y)
grid
axis equal
You can translate the circle (move its centre) by adding appropriate values to the ‘x’ and ‘y’ vectors, and changing its radius involves changing the value assigned to ‘r’. So to move it to be centred at (3,5), add 3 to ‘x’ and 5 to ‘y’. Plotting only a segment of the circle requires you to change the first and second arguments to the linspace call.
Experiment with it! You’ll have your finished plot in a few minutes.
  9 comentarios
Moby Philip
Moby Philip el 25 de Abr. de 2020
Hello @Star Strider can you please elaborate why you choose R4crc = linspace(-pi/2, 0, 30); as from -90. It should be 0 right because you are in X-Axis.
Star Strider
Star Strider el 25 de Abr. de 2020
I chose it because it works in this instance.

Iniciar sesión para comentar.

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by