MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Rotation of 2D graphics

  • To: mathgroup at
  • Subject: [mg26445] Re: Rotation of 2D graphics
  • From: Jens-Peer Kuska <kuska at>
  • Date: Thu, 21 Dec 2000 01:51:47 -0500 (EST)
  • Organization: Universitaet Leipzig
  • References: <91pjqi$>
  • Sender: owner-wri-mathgroup at


say you have a 2d matrix m for the rotation and a center c
define a function


and you with to rotate the 2d graphics gr

gr /. {Point[p_]:> Point[rotate[p]], 
       h:(Line|Polygon)[pts_]:> h[rotate /@ pts],
       Text[a_,p_,opt___]:> Text[a,rotate[p],opt}

and you graphics is rotated. Put all together with

Rotate2D[gr_Graphics, angle_?NumericQ, c : {_?NumericQ, _?NumericQ}] :=
  Module[{m, rotate},
    m = N[{{Cos[angle], -Sin[angle]},
           {Sin[angle], Cos[angle]}}];
    rotate[p : {_?NumericQ, _?NumericQ}] := c + Dot[m, p - c];
    gr /. {Point[p_] :> Point[rotate[p]], 
          (h : Line | Polygon)[pts_] :> 
          h[rotate /@ pts], Text[a_, p_, opt___] :> Text[a, rotate[p],

Yo still need some rules to rotate ContourGraphics[] and
and to transform Disc[] and Cricle[] ...

gg=FullGraphics[Plot[Sin[x], {x, -Pi, Pi}]


Show[Rotate2D[gg, -Pi/4, {0, 0}]]

will rotate it.


Stephen Sheppard wrote:
> I have some graphics generated by showing several 2d plots, and I would like
> to be able to spin these about a specified point.  This is very easy if
> everything has been generated using primitives like Line, Point, etc.  What
> I would like to be able to do is to take an entire image that can be viewed
> using "Show" and rotate it by r radians about the point {x,y}.  Something
> like:
> Show[%]
> ShowRotate[%,r,{x,y}]
> would then produce the graphic with everything (including the axes, labels,
> etc.) rotated.
> Any suggestions?  I would be happy if this were obvious.
> Stephen Sheppard
> Department of  Economics
> Williams College

  • Prev by Date: RE: newbie question on sorting
  • Next by Date: Re: newbie question on sorting
  • Previous by thread: Rotation of 2D graphics
  • Next by thread: RE: Rotation of 2D graphics