Drawing an arc on the end of a straight line
4 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
Star Strider
2015-5-9
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 个评论
Moby Philip
2020-4-25
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!