TransWikia.com

Questions About Implementing Rotational Kinematics in a Game

Physics Asked on July 4, 2021

I’m making a videogame where the player controls a spaceship in a 3d environment, but the catch is the physics are realistic. The thing is, I’m struggling with 3d rotational kinematics. At first I tried manually implementing the physics, but I don’t think I did that right. Thankfully, the game engine I’m using (Godot) does offer a RigidBody class that allows me to apply forces to it and let the game’s physics engine (the bullet engine) figure things out. However, I have noticed some strange behavior that I’m not entirely sure is correct. When I apply multiple different torques at the same time, then stop applying torque, I would expect the angular velocity (given in a 3d vector) to stop changing once I stop applying torque. However, the angular velocity continues to change in both magnitude and direction, which I don’t think is physically accurate. So, I have 2 main questions.

  1. Is my understanding of angular velocity wrong, or is the behavior I described incorrect?
  2. Let’s say I wanted to try manually implementing the physics again. If I have an angular acceleration vector, where the direction of the vector is the axis of acceleration, how do I turn that into an orientation? My old method was to maintain an angular velocity vector, add any accelerations to that velocity vector, then rotating the object around the angular velocity vector with a speed of rotation equal to the magnitude of that vector but I have no idea if that’s physically correct.

Hopefully this is an appropriate place to ask, given that my question is more about physics than game development in my opinion.

One Answer

  1. Your understanding is correct: zero torque means that angular velocity does not change in that timestep

  2. In 2D, angular velocity has a fairly trivial update as $Deltaomega = I^{-1}tau(t)Delta t$, where $I$ is just scalar inertia.

    In 3D, however, the discrete-time update becomes $Deltaomega = QI^{-1}Q^Ttau(t)Delta t$ (assuming Euler integration), where $tau(t)$ is the total torque on the body at that timestep, $I$ is the $3times3$ inertia tensor, and and $Q$ is the (orthogonal) orientation matrix of the body.

    The angular velocity is simply updated as $omega rightarrow omega+Deltaomega$ at the end of the time step.

Correct answer by Nihar Karve on July 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP