OI think that I am committing a basic error that may want to close it, but I am not finding where I am wrong.
This is my code:
r1 = 15; r2 = 8; c = 50; γ = ArcSin[(r1 - r2)/c] // N;
l1 = (2 γ + π) r1
l2 = (π - 2 γ) r2
l3 = 2 c Cos[γ]
L = 2 c Cos[γ] + (2 γ + π) r1 + (π - 2 γ) r2
Here I am creating a graphic:
g=Graphics[{Circle[{0,0},r1,{π/2-γ,((3*π))/2+γ}],
Circle[{c,0},r2,{π/2-γ,-(π/2)+γ}],
Line[{{Cos[π/2-γ]*r1,Sin[π/2-γ]*r1},{Cos[π/2-γ]*r2+c,Sin[π/2-γ]*r2}}],
Line[{{Cos[((3*π))/2+γ]*r1,Sin[((3*π))/2+γ]*r1},{Cos[-(π/2)+γ]*r2+c,Sin[-(π/2)+γ]*r2}}],
PointSize[0.03],
Point[{0,0}],
Point[{c,0}],
PlotRange->{{-100,-100},{100,100}}}]
I want my animation turn in point {0,0}, but something is wrong.
What would it be?
img = Rotate[g, #, {0, 0}] & /@ Range[0, 2 Pi, Pi/6]
Export["Motion.gif", img]
Answer
There were some strange characters in your code (/2 as one Unicode code). Might have been caused by copying your code here. Anyway I corrected them here.
The solution to your problem is the use of GeometricTransformation, which you can apply on graphics elements, not a Graphics object as a whole. Therefore, I removed the Graphics part from g and applied GeometricTransformation to it. Rotate is used to rotate any Mathematica object (not only graphics) and is not suited for this task, as its operation is difficult to align with underlying graphics coordinates.
g = {Circle[{0, 0}, r1, {Pi/2 - γ, ((3*Pi))/2 + γ}],
Circle[{c, 0}, r2, {Pi/2 - γ, -(Pi/2) + γ}],
Line[{{Cos[Pi/2 - γ]*r1,
Sin[Pi/2 - γ]*r1}, {Cos[Pi/2 - γ]*r2 + c,
Sin[Pi/2 - γ]*r2}}], Line[{{Cos[((3*Pi))/2 + γ]*r1,
Sin[((3*Pi))/2 + γ]*r1}, {Cos[-(Pi/2) + γ]*r2 + c,
Sin[-(Pi/2) + γ]*r2}}], Dashed, PointSize[0.03],
Point[{0, 0}], Point[{c, 0}]};
Graphics[GeometricTransformation[g, RotationMatrix[#]] & /@ Range[0, 2 Pi,Pi/6]]

Exporting to an animation:
Export["D:\\Users\\Sjoerd\\Desktop\\test.gif",
Graphics[GeometricTransformation[g, RotationMatrix[#]],
PlotRange -> {{-70, 70}, {-70, 70}}] & /@ Range[0, 2 Pi, Pi/20]]


Comments
Post a Comment