0
$\begingroup$

I don't understand why Rotate[] and Translate[] behave differently. For example, ga and gb below look as I expected:

ga = Graphics[Line[{{0, 0}, {1, 0}}]];
Print[ga];
gb = Rotate[ga, \[Pi]/4, {0, 0}];
Print[gb];
gc = Translate[gb, {1, 1}];
Print[gc];

But gc results in this: enter image description here

$\endgroup$

1 Answer 1

1
$\begingroup$

Your problem here is that you are calling Graphics too early. You want to Rotate and Translate the Line, not the Graphics.

ga = Line[{{0, 0}, {1, 0}}];
Graphics[ga]
gb = Rotate[ga, \[Pi]/4, {0, 0}];
Graphics[gb]
gc = Translate[gb, {1, 1}];
Graphics[gc]

Will do what you want.

Graphics[{Red, ga, Blue, gb, Green, gc}]

enter image description here

$\endgroup$
3
  • $\begingroup$ Thank you! ${}{}$ $\endgroup$ Sep 5, 2020 at 15:15
  • $\begingroup$ Happy to help! :) $\endgroup$
    – Carl Lange
    Sep 5, 2020 at 15:15
  • $\begingroup$ @JosephO'Rourke just to add to this: for some reason WRI decided that Rotate should also be able to rotate arbitrary stuff displayed on the screen outside of a Graphics call, which is why your gb seemed to work. $\endgroup$
    – b3m2a1
    Sep 30, 2020 at 21:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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