Drawing an arc on the end of a straight line

4 ビュー (過去 30 日間)
Chris cjsholmes@hotmail.com
Chris cjsholmes@hotmail.com 2015 年 5 月 9 日
コメント済み: Star Strider 2020 年 4 月 25 日
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.

回答 (1 件)

Star Strider
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
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.
Star Strider
Star Strider 2020 年 4 月 25 日
I chose it because it works in this instance.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by