How to connect a line between two moving points?

3 ビュー (過去 30 日間)
Pablo González de la Parra
Pablo González de la Parra 2020 年 10 月 15 日
Hello! I am trying to model a sliding-crank mechanism using fanimator's and simple fplot's. I´ve managed to model the movement of the "crank" or the circle, and also the movement of the "slide" or the horizontal movement. But I am asked to unite these moving points with a line (that can move obviously with them and without changing its lenght) in order to represent the "connecting rod" to finish the mechanism. So, how can I make this line so when the "animation" runs the mechanism looks complete?
r=5;
l=20;
f = @(t) plot(r*cos(t), r*sin(t), "ro", "MarkerFaceColor", "r", "MarkerSize", 16);
fanimator(f,"AnimationRange", [0 6*pi]);
hold on
g = @(t) plot(r*cos(t)+sqrt(l^2-r^2*sin(t)*.2),0, "ro", "MarkerFaceColor", "r", "MarkerSize", 16);
fanimator(g,"AnimationRange", [0 25]);
hold off
syms t
x = r*cos(t);
y = r*sin(t);
x1 = t;
y1 = t-t;
hold on
fplot(x, y, [0,2*pi])
title("Circulo")
hold off
hold on
fplot(x1, y1, [15, 25])
title("Linea Recta")
hold off

採用された回答

Swatantra Mahato
Swatantra Mahato 2020 年 10 月 19 日
Hi Pablo,
Assuming you want to join the points representing the "crank" and the "slide", you can do this in a similar way how you generated the points. You can include the following lines in your script:
rod=@(t)plot([r*cos(t),r*cos(t)+sqrt(l^2-r^2*sin(t)*.2)],[r*sin(t),0]);
fanimator(rod,"AnimationRange",[0 6*pi]);
Here rod is a line connecting the points representing the "crank" and the "slide" and fanimator enables the rod to move along with the points for the same time as "crank" (6*pi).
Hope this helps
  1 件のコメント
Pablo González de la Parra
Pablo González de la Parra 2020 年 10 月 22 日
Thank you very much! That really helped me a lot!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by