I'm a beginner in mathematica. I'm making a nb that calculates the output angle of a fourbar mechanism based on the input angle. So the input is the length of the four linkages and the input angle of the crank and the output is the angle of rocker.
I've already made my code and it works well. I plot it in a graphics as well. Now I want to trace the point B which is the TIP of the coupler. I want to trace the path of motion of this point to plot the output curve.
outputAngle[r1_, r2_, r3_,
r4_, ϕ_] := (* r1 is the crank; r2 is the coupler; r3 is the \
rocker; r4 is the link between oA and oB; ϕ is the input angle \
of the crank; This function calculates the output angle of the \
rocker.*)
{a1 = N[Sin[ϕ Degree]],
b1 = N[r4/r1 + Cos[ϕ Degree]],
c1 = N[r4/r3 Cos[ϕ Degree] +
N[(r1^2 - r2^2 + r3^2 + r4^2)/(2 r1 r2)]],
ψ =
2 ArcTan[N[(a1 + √(a1^2 + b1^2 - c1^2))/(b1 + c1)]]/
Degree,(*Output Angle Calculated by Equation from the refrence*)
a2 = N[AngleVector[{r1, ϕ Degree}]],(*point A Starting from \
origin*)
b2 = N[AngleVector[{-r4,
0}, {r3, ψ Degree}]],(*Point B Starting from Ob*)
N[AngleVector[{-r4, 0}]],(*Point oB*)
d = √((b2[[1]] - a2[[1]])^2 + (b2[[2]] -
a2[[2]])^2) (*distance between A & B This is just to confirm \
that a2's length is constant*)
}
Slider[Dynamic[t], {0, 720, 1}]
Dynamic[
m = outputAngle[2, 8, 6, 6,
t] (*This is the passing of values to the main function that \
calculates the output angle*)
]
Dynamic[ (*This is the drawing of the four bar linkage out put*)
Graphics[{
Line[{{0, 0}, m[[5]]}],
Line[{m[[5]], m[[6]]}],
Line[{m[[7]], m[[6]]}],
Line[{{0, 0}, m[[7]]}],
Locator[m[[6]]]
}, Axes -> True, PlotRange -> {{-9, 6}, {-3, 8}}]
]
That is my code. I made sure to comment all the inputs so it makes sense. I need to trace the point B or m[[6]] in the graphics area. Any help?


outputAnglefunction already gives you the coordinates of that path, so would it be acceptable to add a pre-calculated path to your plot, i.e. something likeLine@Table[outputAngle[2, 8, 6, 6, t][[6]], {t, 0, 360, 1}]inside theDynamic[Graphics[...]]that produces your main output? – MarcoB Aug 19 '15 at 14:01