Message Boards Message Boards

Trying to rotate 3D Plot (using Rotate and ImageRotate)

Posted 9 years ago

Hello!

I am trying to use ImageRotate to rotate my image by Pi/3 around a specific axis. Here's what I'm trying to do. First I make a 3D plot:

a = SphericalPlot3D[1, {\[Theta], 0, \[Pi]}, {\[Phi], 0, 2 \[Pi]}, 
  ColorFunction -> 
   Function[{x, y, z, \[Theta], \[Phi], r}, 
    ColorData["DarkRainbow"][
     E^-((\[Theta] - \[Pi]/2)^2/(2 \[Sigma]) + (\[Phi] - \[Pi])^2/(
        2 \[Sigma]))]], ColorFunctionScaling -> False, Mesh -> True, 
  Boxed -> False, Axes -> False, PlotPoints -> 150, 
  ViewPoint -> {-2, 0, 0}, ImageSize -> 300]

enter image description here

Now I can rotate it using ImageRotate:

ImageRotate[a, Pi/3]

enter image description here

But now if I try and rotate around a specific axis (exactly the same way as the documentation), I get an error message:

ImageRotate[a, {Pi/3, {1, 0, 0}}]
 ImageRotate::imgang: Angle {\[Pi]/3,{1,0,0}} should be a real number, one of Top, Bottom, Left, Right, or a rule from one to another. >>

Also I tried using Rotate a similar thing happens i.e. I can do it without choosing an axis:

Rotate[a,Pi/3}

enter image description here

But I get an error if I do

Rotate[a,Pi/3,{1,0,0}]
Coordinate {1, 0, 0} should be a pair of numbers, or a Scaled or Offset form.

Does anybody why this is happening?

Thank you!

4 Replies
Posted 8 years ago

Hello,

Rotate works on graphics primitives (Sphere, Cylinder, Cuboid ...). ListContourPlot3D is not a graphics primitive.

In 3D, Rotate can rotate around any given 3D vector. Check this:

 Manipulate[
   Show[
     Graphics3D@Sphere[],
     Graphics3D@Rotate[Cuboid[], angle, {1, 0, 0}],
     PlotRange -> {{-1.5, 1.5}, {-1.5, 1.5}, {-1.5, 1.5}}
   ],
   {{angle, 0}, -\[Pi], \[Pi]}
 ]
POSTED BY: Hans Milton
Posted 8 years ago
POSTED BY: Juan Tamara

Mathematica distinguishes between "Images" and "Graphics". See the documentation for information about them.

ImageRotate is for Images, but SphericalPlot3D produces a Graphic.

There is a specific function for Graphics rotation: https://reference.wolfram.com/language/ref/Rotate.html

Rotate[a, Pi/2, {0, 0, 1}]

Another way to do this is to use the ViewPoint option: http://reference.wolfram.com/language/ref/ViewPoint.html

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

Group Abstract Group Abstract