Rotation of 3D Plot using Euler angles

In summary: I created a single complex graphic object and rotated it using the Rotate command. I think this is the best way to go for parallelized calculations.
  • #1
Mr. Rho
15
1
So, I'm trying to plot a 3D "dipole" (an arrow with a small torus around it basically) in mathematica, and want to rotate it according to Euler angles...

I use this code for the rotation matrix:

rot[a, b, g] := RotationMatrix[g, {1, 0, 0}].RotationMatrix[b, {0, 1, 0}].RotationMatrix[a, {0, 0, 1}]

and I obtain the standard Euler angles rotation matrix.

For the arrow and the torus I'm using:

arrow[x_, y_, z_,a_, b_, g_, r_] := Graphics3D[{Red, Cone[{rot[a, b, g].{0, 0, 2^4 r} + {x, y, z}, rot[a, b, g].{0, 0, 2^4 r + 2^2 r} + {x, y, z}}, 3 r], Cylinder[{rot[a, b, g].{0, 0, 0} + {x, y, z}, rot[a, b, g].{0, 0, 2^4 r} + {x, y, z}}, r]}]

torus[x_, y_, z_, a_, b_, g_, r_] := ParametricPlot3D[rot[a, b, g].{(r*Cos[m] + 4 r) Cos[v], (r*Cos[m] + 4 r) Sin[v], r*Sin + z} + {x, y, z}, {m, 0, 2 Pi}, {v, 0, 2 Pi}, Mesh -> None, PlotStyle -> {Green, Opacity[.25]}]

(Note that I also introduced a boost) The next step is to show both plots using manipulate to change the angle and boost values, the code I use is simply:

Manipulate[Show[arrow[x,y,z-8,a,b,g,1], torus[x,y,z,a,b,g,1]], {x,0,1}, {y,0,1}, {z,0,1}, {a,0,2Pi}, {b,0,2Pi}, {g,0,2Pi}]

Everything is ok until here, the plot of a dipole is shown and it moves smootly. The problem is when I start introducing more and more arrows and torus. If I want, for example, 4 dipoles, the plot gets really really slow...

So, any plot optimization tips?

Thank you for your help!
 
Last edited:
  • #3
I have seen complex combinations of plots bog down in a Manipulate. It seems doing only 4 dipoles (each with a Graphic3D and a ParametricPlot3D) shouldn't be too bad, but that may depend on the CPU/cores/memory of your system. Did you integrate each of the 4 within the one Graphic3D and one ParametricPlot3D or are you processing 8 separate delayed functions and then Show'ing that?

If so, you might also try creating a single (complex) graphic object and use a Rotate command against that (instead of doing all the ParametricPlot3D's for each).

In a worst case scenario when I have hundreds or thousands of objects floating around a 3D space (e.g. where I am doing a parallelized CPU or GPU based simulation of some early inflationary Universe N-Body gravitational model of theoretical particles), I create a 2D raster of it and simply do an Inset of that into the 3D space.
 
Last edited:
  • Like
Likes Mr. Rho
  • #4
J Gregory Moxness said:
I have seen complex combinations of plots bog down in a Manipulate. It seems doing only 4 dipoles (each with a Graphic3D and a ParametricPlot3D) shouldn't be too bad, but that may depend on the CPU/cores/memory of your system. Did you integrate each of the 4 within the one Graphic3D and one ParametricPlot3D or are you processing 8 separate delayed functions and then Show'ing that?

If so, you might also try creating a single (complex) graphic object and use a Rotate command against that (instead of doing all the ParametricPlot3D's for each).

In a worst case scenario when I have hundreds or thousands of objects floating around a 3D space (e.g. where I am doing a parallelized CPU or GPU based simulation of some early inflationary Universe N-Body gravitational model of theoretical particles), I create a 2D raster of it and simply do an Inset of that into the 3D space.

Hi Gregory, thank you for your reply. The solution for me was processing the 4 separate dipoles and then showing that as you say, the problem was that I was trying to plot all the four dipoles at the same time
 
  • Like
Likes J Gregory Moxness

Related to Rotation of 3D Plot using Euler angles

1. What are Euler angles?

Euler angles are a set of three angles used to describe the orientation of a rigid body in 3D space. They are typically denoted as roll, pitch, and yaw angles.

2. How are Euler angles used in 3D plot rotation?

Euler angles are used to rotate a 3D plot by specifying the amount of rotation around each of the three axes of the plot. This allows for precise control over the orientation of the plot.

3. What are the advantages of using Euler angles for 3D plot rotation?

Euler angles provide a simple and intuitive way to specify rotations in 3D space. They also allow for easy decomposition of complex rotations into simpler ones.

4. Can Euler angles cause gimbal lock?

Yes, Euler angles can cause gimbal lock, which occurs when the rotation axes align and the rotation becomes ambiguous. This can result in unexpected behavior and loss of control over the orientation of the plot.

5. Are there any alternatives to using Euler angles for 3D plot rotation?

Yes, there are other methods for specifying 3D rotations, such as quaternions and rotation matrices. These methods may offer better numerical stability and avoid gimbal lock, but may be more complex to understand and use.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
343
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
6K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
Back
Top