Physics programming calculating percent of thrust from quaternion

I was wondering how to calculate thrust and its ratio in c++ using bullet physics for each thruster and save it in a array with the cardinal direction and amount of thrust..

A diagram is here https://imgur.com/a/VIIpy . There is a parent rigid body with child rigid bodies with the direction as forward. The parent rigid body is a ship. I can get the rotation of each thruster by simple quaternion multiplication but the issue is with the cardinal direction. The other thing I can think of as to thurst multiply the cardinal direction to the child rigid body. Then somehow using the result either it would be atan.

For example, if a thurster is north, west, and up attached to the parent rigid body but the thurster forward direction is pointing east and south 45 degrees forward. It's main thrust is 120. So thrust would actually be east and south, possible 50% going east and 50% going south.

Steps 1
Get the rotation of thruster rigid body in relation to the cardinal direction

If I have to assume the math to get the difference rotation

Thruster1 q1 = rotation(q) * Vector3::RIGHT * Vector3::UP;

Step 2
Convert the quaternion to degrees

Step 3
Using tangent using something like
tangent(angle*Math.PI/180)

It would give me the tangent angle.

Step 4
Use the tangent angle information multiply by the thrust

Any ideas or help to pdf or docs. I'm not a calculus or algebra major. I welcome any comments or advice.
Last edited on
I have no idea what "ratio of thrust" or "bullet physics" are, but you seem to be going off on a tangent (or perhaps I will).

You have a 3D (rigid body) object. Its coordinates are probably on its own "frame of reference". In order to put it in specific location and orientation in the "world frame", you rotate and translate all object points to get their "world coordinates".

A rotation has two components: an axis and angle. Coordinates on the axis of rotation do not change at all. Quaternion can represent axis and angle, but the axis crosses (0,0,0). To get an arbitrary rotation axis, you do need translation too.

The thruster is an object too. It could be on the ship's frame, but it could be on its own frame too, to make thruster rotations simpler.

Lets say you turn the thruster. That is just rotation. Then you translate the thruster from its frame into ship's frame. Now you can apply ship's rotation and translation to get the thruster's world coordinates.

When the thruster does a "burn", the point of the ship where the thruster is connected to is inclined to move to the opposite direction. That would cause rotation, unless the direction of the force is aligned with the center of mass of the ship and the thruster position.


No matter what, directions do not translate. They only rotate. If you do have a direction (a 3D vector) and apply the rotations, then you get a new direction vector (in some frame of reference).

Assuming the direction vector has length of 1, then its coordinates (x,y,z) are component vectors (x,0,0), (0,y,0), (0,0,z) in the frame of reference.

"South-East" is not 50% to South and 50% to East. It is 1/sqrt(2) = 70.7% to South and 70.7% to East.
quaternions work just like regular angles conceptually, its just a storage trick to save extra values so that you have redundant terms that don't get 'lost' at the straight up twist scenario (what the problem they solve is that if you go straight up, rotate, and then fall back down, the orientation of the object is lost in the zero angle trig functions). They are high school math, really so you do need a touch of trig and algebra to really get it. All the equations you need for them should be online on any math/wiki type page; all you need is to store 4 values that are related by some trig, and use them as directed to represent the 3-d angles as normal.

ballistics is different from rocketry, .. ballistics have no more thrust after initial, rockets carry fuel.

learn about atan2. It is your friend.

we can help you but there isn't a way around you reading a quaternion wiki and implementing the equations for it to convert to and from normal angles & using them in the math.

realistic models get frustrating fast... the fuel mass changes constantly, air has different density as you go up, eventually even gravity changes (significantly, it changes a little right away) to name a couple of issue. What is this for... much of this is a lot easier with calculus, and not having had it, this is a really ambitious program without?
Last edited on
Topic archived. No new replies allowed.