Showing rotational trajectory with Python

In summary: 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?The simplest way is to use a coordinate system that is fixed with respect to the object.In summary, you would need to create a coordinate system that is fixed with respect to the object, and use that coordinate system to map out the trajectory of the rotation.
  • #1
Avatrin
245
6
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?
 
Technology news on Phys.org
  • #2
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?
 
  • #3
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 + 2If 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.:smile:
 
Last edited:
  • #4
I should've been clearer. I don't think your issue applies in this case... I have this:

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

Here [itex]I = [0,a][/itex] for some real, positive number a is a closed interval. So, if, for some closed subinterval, the turning occurred 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, let's say the north pole. I want to see how the north pole moves around given the angular velocities I have available.
 
  • #5
Avatrin said:
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.
 
  • #6
PeterDonis said:
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. Let's 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.
 
  • #7
Avatrin said:
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.
 
  • #8
PeterDonis said:
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...

PeterDonis said:
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?
 
  • #9
Avatrin said:
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.

Avatrin said:
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):

http://www.feynmanlectures.caltech.edu/I_20.html
 
  • Like
Likes Avatrin

1. How do I create a rotational trajectory using Python?

To create a rotational trajectory using Python, you will need to use the appropriate libraries and functions. One popular library for creating 3D animations and visualizations is PyOpenGL. You can use its rotation functions, such as glRotatef(), to rotate an object in 3D space.

2. Can I plot a rotational trajectory in 2D using Python?

Yes, you can plot a rotational trajectory in 2D using Python by using the matplotlib library. You can use the functions plt.plot() or plt.scatter() to plot the trajectory of a point or object as it rotates around a fixed point.

3. How can I animate a rotational trajectory in Python?

You can animate a rotational trajectory in Python by using the animation module from the matplotlib library. The FuncAnimation class allows you to create a sequence of frames that can be displayed as a GIF or video, showing the rotation of an object.

4. What are some useful mathematical concepts for creating a rotational trajectory in Python?

To create a rotational trajectory in Python, you will need to understand concepts such as rotation matrices and quaternions. These mathematical concepts help to describe and calculate the rotation of an object in 3D space and can be implemented using libraries such as NumPy.

5. Can I use Python to simulate real-world rotational trajectories?

Yes, Python can be used to simulate real-world rotational trajectories by incorporating physical laws and equations into your code. For example, you can use the Euler-Lagrange equations to simulate the motion of a rigid body in 3D space and visualize its rotational trajectory using Python.

Similar threads

  • Programming and Computer Science
Replies
10
Views
2K
  • Programming and Computer Science
Replies
3
Views
311
  • Programming and Computer Science
Replies
1
Views
9K
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
1
Views
726
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
8
Views
2K
  • Programming and Computer Science
2
Replies
56
Views
8K
  • Programming and Computer Science
Replies
4
Views
4K
Back
Top