Thursday, January 17, 2019

rotation - How do you calculate the rotational velocity of a flying object?


When a arrow shaped object is fired it slowly adjusts it's rotation to match the direction it is moving. But what is the actual physics behind it?


enter image description here


The question is: How many degrees does the ship turn in a second?


I usually approximate the effect by simply setting the rotation to the angle of the velocity, however this is not possible this time since the player is able to influence the rotation of the ship by steering.



Answer



1: Simple physics


There will be a subtle difference in drag on either side*, because the side rotating into the wind will have greater dynamic pressure than the one that rotates with the wind. For an arbitrary shape, this will be somewhat difficult to calculate (although possible) for correct physics. You should not try, and approximate it instead. This approximation can simply be proportional to flow velocity. This is sort of physically accurate, and very simple to calculate.


For a ship, which presumably has roughly the same shape as an arrow with something "draggy" at the downstream end of it, this effect will be proportional to the ship's alignment with the direction. For example, (1 - direction.dot(rotation)) might work well. This will also be affected by the magnitude of rotational speed.


So for an overall system, rotational acceleration due to drag will be roughly:



velocity.length * rotationSpeed * (1 - direction.dot(rotation)) * 
SOME_UNSCIENTIFIC_CONSTANTS * getDragRotationDirection();

This will likely result in an oscillating rotation. It will bounce around its own aligned direction. You will need to tweak the code to dampen that somehow.


2: for 2D physics-based system:


Treat the tail-fins (or whatever) as the location to apply a constant impulse proportional to velocity in the direction opposite velocity. Because this location should be offset from the center of mass, it will yield a moment that will rotate the ship back toward the forward-direction. When the ship is aligned with that direction, it will yield no rotation.


For this method, be wary of the special case where the tail is pointed almost directly into the wind. That might yield weird results.




*Side: The cross product of the flow direction (opposite direction of movement) and the axis of rotation (for 2D, unit-z), will yield a "side". The other side is the opposite direction.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...