Group Abstract Group Abstract

Message Boards Message Boards

0
|
14.7K Views
|
9 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Rotate the coordinate system

Posted 10 years ago

Hello everybody

I like to plot following graphic: enter image description here

Basically I have two coordinate systems. Coordinate system "A" which is not tilted and a coordinate system "B" which is rotated at the origin by an angle alpha. In coordinate system "B" I plot the cos-function which seems rotated when looking from coordinate system A. The gray shaded area which you can see in the picture is not important.

How can I plot this? I have no idea :-(. I already tried it with the Mathematica-function Rotate.

Hope you can help me to solve this problem. Thank you very much.

POSTED BY: Peter Parker
9 Replies

Great, thank you guys for your help. I really appreciate it.

Best regards,

Peter

POSTED BY: Peter Parker
POSTED BY: Henrik Schachner
POSTED BY: Peter Parker
POSTED BY: Peter Parker
POSTED BY: Henrik Schachner

Hello Peter,

This will display the rotated plot:

Rotate[Plot[Cos[x], {x, -2*\[Pi], 2*\[Pi]}], 30 Degree]

However, you only get the rotated axes, not the straight ones. You can put it inside another plot, just to get straight axes:

Plot[0, {x, 0, 1}, PlotRange -> {{-2*\[Pi], 2*\[Pi]}, {-3, 3}}, 
 Epilog -> 
  Inset[Rotate[Plot[Cos[x], {x, -2*\[Pi], 2*\[Pi]}], 30 Degree]]]

You can play with the ranges and the size of the Inset to get things right. I cannot say I like the idea of using an additional call to Plot just to generate axes, but I am not being able to display the output of Rotate with Graphics, even if I first evaluate FullGraphics on it. If you could display it with Graphics, then you could display the straight axes and even a frame, if desired.

You may want to see:

http://mathematica.stackexchange.com/questions/80505/how-to-plot-functions-in-multiple-coordinate-systems

and

http://mathematica.stackexchange.com/questions/1003/is-there-an-equivalent-of-fullgraphics-for-graphics3d

OL.

POSTED BY: Otto Linsuain

Hi Peter,

here comes a crude approach, but maybe this goes in the right direction:

img0 = Image@
   RotateLeft[ (* `RotateLeft` is for fine tuning ... *)
    ImageData@
     ColorConvert[
      Plot[0, {x, -10, 10}, PlotRange -> {{-10, 10}, {-4, 4}}, 
       ImageSize -> 500], "Grayscale"], {0, 2}];

img1 = ImageRotate[
   Plot[3 + Sin[x], {x, -10, 10}, PlotRange -> {-4, 4}, 
    PlotStyle -> Green, ImageSize -> 500], -10 \[Degree], 
   Background -> White];

ImageMultiply[img1, img0]

which gives:

enter image description here

Regards -- Henrik

POSTED BY: Henrik Schachner

Hi

thank you Otto for your answer. This is only partially what I am looking for. The code that you gave me shows a cos-function rotated by an angle. Now I would like to have a second coordinate system on top of this plot which is rotated by the same angle. Just like in the picture I included in my first post. That is the big challenge for me.

Best regards,

Peter

POSTED BY: Peter Parker

Hello Peter,

Not sure whether this is what you are looking for. At least I hope it will provide a starting point:

ParametricPlot[
 Evaluate[Dot[RotationMatrix[\[Pi]/12], {x, Cos[x]}]], {x, -2*\[Pi], 
  2*\[Pi]}]

Not sure how to paste the image but it looks like a rotated cosine graph. Notice that the default AspectRatio for ParametricPlot is Automatic, meaning the horizontal and vertical scales are equal. This is different than the default value in Plot. This may become important if you want to display them together.

OL.

POSTED BY: Otto Linsuain
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard