3
$\begingroup$

I want to rotate some figure. For example

fig0 = Plot[0.001 Sin[x], {x, 0, Pi}, Axes -> False]
Show[fig0 /. prim : _Line | _Point | _Polygon :>
   GeometricTransformation[prim, RotationTransform[Pi/3, {0, 0}]], 
 PlotRange -> All]

The sine curve after rotation becomes a straight line. How can I make the figure remain the original shape after rotation?

$\endgroup$
5
$\begingroup$

It is because amplitude of your Sin function is very small relative to the length of its arc (you picked 0.001 Sin[x]), so it looks almost flat when you rotate it. You can see it non-flat initially because Mathematica auto-rescales Y-axes to zoom in on your small amplitude. When you rotate by Pi/3 curve that is Pi-long in base, its end lifts by Pi Tan[Pi/3] or N[Pi Sqrt[3]] or ~ 5.4414. Relative to this hight .001 will not bee seen. You can see that there is nothing wrong with rotation if you pick amplitude comparable to the length arc:

fig0=Plot[Sin[x],{x,0,Pi},Axes->False];
Manipulate[
    Graphics[
        GeometricTransformation[fig0[[1]],RotationTransform[r]],
    Frame->True,Axes->True,PlotRange->3],
{r,0,2Pi}]

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ Thanks for your answer. Is these a way to rotate the figure with original shape even though the y range is relatively small compared with x range, as if the canvas is rotated. $\endgroup$
    – Ice0cean
    Mar 13 '20 at 5:28
  • $\begingroup$ @Ice0cean I added explanation in reply. $\endgroup$ Mar 13 '20 at 5:35
2
$\begingroup$

You can replace RotationTransform[Pi/3, {0, 0}]] with

ScalingTransform[{1, 10^-3}] @* 
  RotationTransform[Pi/3, {0, 0}] @* ScalingTransform[{1, 10^3}]

to avoid the issue caused by different scales (as explained by Vitaliy).

sRs = ScalingTransform[{1, 1/1000}] @* RotationTransform[#, {0, 0}] @*
  ScalingTransform[{1, 1000}] &;

Manipulate[Show[fig0, 
    MapAt[GeometricTransformation[#, sRs[t]] &, fig0, {1}] /. l_Line -> {Red, l}, 
  PlotRange -> {{-3, 3}, {-.003, .003}}, Axes -> True, Frame -> True, AspectRatio -> 1],
 {{t, Pi/3.}, 0., 2. Pi, Appearance -> {"Labeled", "Open"}}]

enter image description here

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.