I am new to this forum - I wonder if someone can help me improve this code.
I would like the angle $\theta$ to start in the middle of the slider i.e. $\theta = 0$ instead of starting at $\theta = -90$.
How do I keep the circle size constant as I slide the $\theta$?
Mohr[σxx_, σyy_, τxy_] :=
DynamicModule[{g1, g2, g3}, OC = 1/2*(σxx + σyy);
R = Sqrt[((σxx - σyy)/2)^2 + τxy^2] ;
g1 = {Thickness[0.01], Circle[{OC, 0}, R]}; σxx1 :=
1/2*(σxx + σyy) + 1/2*(σxx - σyy)*Cos[2*θ*Degree] + τxy*
Sin[2*\[Theta]*Degree];
σyy1 := 1/2*(σxx + σyy) + 1/2*(σyy - σxx)*Cos[2*θ*Degree] - τxy*Sin[2*θ*Degree];
τxy1 := 1/2*(σyy - σxx)*Sin[2*θ*Degree] + τxy*Cos[2*θ*Degree];
τxy1a := 1/2*(σyy - σxx)*Sin[(2*θ*Degree + π)] + τxy*Cos[(2*θ*Degree + π)];
pts = {{σxx1, -τxy1}, {σyy1, -τxy1a}};
g2 = {PointSize[0.05], Red, Point[pts] ,
Inset[Row[{"\!\(\*SubscriptBox[\(σ\), \(xx\)]\) = ", NumberForm[σxx1, {6, 2}], ";",
" \!\(\*SubscriptBox[\(τ\), \(xy\)]\) = ", NumberForm[-τxy1, {6, 2}]}],
Dynamic[{pts[[1, 1]], pts[[1, 2]]}]],
Inset[
Row[{"\!\(\*SubscriptBox[\(σ\), \(yy\)]\) = ", NumberForm[σyy1, {6, 2}], ";",
" \!\(\*SubscriptBox[\(τ\), \(xy\)]\) = ", NumberForm[-τxy1a, {6, 2}]}],
Dynamic[{pts[[2, 1]], pts[[2, 2]]}]]
} ;
g3 = {Thickness[0.01], Blue, Line[pts]};
{Column[{Graphics[{g1, Dynamic[g2], Dynamic[g3],
Inset[Text[Style["Mohr's circle", 18, Purple, Italic]], {49.58, 68.99}]},
ImageSize -> 300 ],
Row[{"θ = " Slider[Dynamic[θ], {-90, 90}], Dynamic@θ " degree"}]}]}]
Mohr[100, 0, 25]
Edit
barebones version
Mohr[x_, R_] :=
DynamicModule[{g1, g2},
g1 = Circle[{x, 0}, R];
pts = Dynamic @{{R Cos@t + x, R Sin@t}, {R Cos[t + Pi] + x, R Sin[t + Pi]}};
g2 = {PointSize[0.05], Red, Point[Dynamic@pts],
Inset["A very long text", Dynamic@(pts[[1, 1]])]};
{Column[{Graphics[{g1, Dynamic[g2]}, Axes -> True],
Row[{"t = " Slider[Dynamic[t], {-Pi/2, Pi/2}], Dynamic@t }]}]}]
Mohr[100, 25]
Slider
in the documentation. Let us know if you get stuck $\endgroup$