# Showing rotational trajectory with Python

#### Avatrin

Hi

I have a list of 3D angular velocities (a numerical solution to an ODE). I want to show the trajectory this rotation would cause by mapping it out on the unit sphere. How can I go about doing that? What is the best way to approach this?

Related Programming and Computer Science News on Phys.org

#### Avatrin

Okay, it looks like this may not be easy. Does anybody here have any suggestion regarding how I can show the trajectory of a rotation given the list of 3D angular velocities?

#### jartsa

Isn't it simple like this:

If a body turns 1 degree in one second around x-axis, and during that same second it also turns 2 degrees around y-axis, then the new angles are: old x-angle + 1 , old y-angle + 2

If the turning around the x-axis occurred mostly during the first half of the second and the turning around the y-axis occurred mostly during the last half of the second, that would be problematic.

Oh yes, it was simple because I considered just one sample of the many different angular velocities.

Last edited:

#### Avatrin

I should've been clearer. I don't think your issue applies in this case... I have this:

$\omega(t_n) = [\omega_x(t_n),\omega_y(t_n),\omega_z(t_n)]_{t_n \in I}$

Here $I = [0,a]$ for some real, positive number a is a closed interval. So, if, for some closed subinterval, the turning occured along the x-axis before the y-axis, that information already is contained in my list.

Also, my initial condition for position is any point on the unit sphere. So, lets say the north pole. I want to see how the north pole moves around given the angular velocities I have available.

#### PeterDonis

Mentor
I have a list of 3D angular velocities (a numerical solution to an ODE). I want to show the trajectory this rotation would cause by mapping it out on the unit sphere.
If motion is constrained to the unit sphere, then three angular velocities is too many; motion on the unit sphere only requires two angles to specify it completely, so you should only have two angular velocities.

#### Avatrin

If motion is constrained to the unit sphere, then three angular velocities is too many; motion on the unit sphere only requires two angles to specify it completely, so you should only have two angular velocities.
Well, technically, I am modelling the rotation of some rigid body. Lets be more specific:

It has a diagonal inertia matrix, and no external force is acting on it. So, together with some initial conditions, Euler's rotation equations gives me a system of ODE's which I can use to calculate its rotational motion. I have been tasked with visualizing the resulting motion in three dimensions... in a still image...

I am open for suggestions of other ways of doing this.

#### PeterDonis

Mentor
I have been tasked with visualizing the resulting motion in three dimensions... in a still image...
I'm not sure how one would visualize motion with a still image. Wouldn't you want to make a video? Or at least a succession of still images showing what the object looks like at a succession of times?

As for numerically simulating the motion, the simplest way is just to update the position vector of each point (or, since you have to discretize, each small piece) of the object at each time step, using the fact that the velocity of that point will be a sum of terms of the form $\mathbf{\omega} \times \mathbf{r}$, where $\mathbf{\omega}$ is one of the angular velocity vectors (each such vector points along one of the three axes of rotation and has magnitude equal to the angular velocity about that axis) and $\mathbf{r}$ is the distance of the point from the axis of rotation for that angular velocity.

#### Avatrin

I'm not sure how one would visualize motion with a still image. Wouldn't you want to make a video? Or at least a succession of still images showing what the object looks like at a succession of times?
Well, yeah, and that's my issue.. That's why I thought that visualizing the motion of a point on the surface of a sphere would do; It creates a trajectory which does show how a rigid body with the same center of mass would rotate given the same angular velocities...

As for numerically simulating the motion, the simplest way is just to update the position vector of each point (or, since you have to discretize, each small piece) of the object at each time step, using the fact that the velocity of that point will be a sum of terms of the form $\mathbf{\omega} \times \mathbf{r}$, where $\mathbf{\omega}$ is one of the angular velocity vectors (each such vector points along one of the three axes of rotation and has magnitude equal to the angular velocity about that axis) and $\mathbf{r}$ is the distance of the point from the axis of rotation for that angular velocity.
Hmm, I am not entirely sure what you mean. I am willing to try this out. What book or online lectures can I use to understand this?

#### PeterDonis

Mentor
That's why I thought that visualizing the motion of a point on the surface of a sphere would do; It creates a trajectory which does show how a rigid body with the same center of mass would rotate given the same angular velocities
Ah, I see. You could use the same method I described for just that one point to generate a trajectory; because the velocity is always perpendicular to the position, the point's distance from the center of the sphere will never change.

What book or online lectures can I use to understand this?
If the formula $\mathbf{\omega} \times \mathbf{r}$ doesn't already look familiar to you, you probably need to review the basic math of rotation. That formula just gives the velocity vector of a point at position $\mathbf{r}$ due to the angular velocity $\mathbf{\omega}$. The treatment in the Feynman Lectures on Physics, Ch. 20 is pretty good (section 20.2 gives the formula I just gave, as well as other formulas involving cross products, which are helpful in simplifying the equations):

"Showing rotational trajectory with Python"

### Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving