How would I get 3d acceleration from a force vector?

I’ve got a numerical simulation of a rocket launch in 3d. I’m stuck on the part where I calculate linear acceleration on all three axes.

In 2d, I’d say ax = thrust * sin(thrustangle) / mass and ay = -g + thrust * cos(thrustangle) / mass.

But in 3d, the x and y angles both affect the z component of the force.

I’ve got a thrust magnitude and a thrust quaternion of rotation.

How would I convert that to an acceleration vector?

Your 2D implementation is a long hand variant of applying a rotation to a 2D vector (plus also gravity after that)

The quaternion defines a rotation for a given transformation. In the quaternion docs

you can see that the rotation is applied to a given vector.

var vector = new THREE.Vector3( 1, 0, 0 ); vector.applyQuaternion( quaternion );

You can define one such vector as forward (whether it be (1,0,0) or (0,0,1) or what have you) and the magnitude of the vector can be multiplied in. eg. vector.multiplyScalar(magnitude). This would give you something like (if magnitude is 3) 3*(1,0,0) = (3,0,0). Then applying the quaternion will rotate this thrust vector (with the needed magnitude) to point in the required direction. Lastly, you’d want to apply gravity acceleration in the y direction on top of the thrust vector, so you’d take the result from the previous step and add to it the vector (0,-g,0) (assuming y is up).

Hope that helps!

Yes this looks like what I did after I wrote this question and it seems to be working well! Thanks!

Here’s the code snippet:

const getAccelerationVector = (

  thrust: number,

  thrustAngle: Quaternion,

  mass: number

) => {

  const vector = new Vector3(0, 1, 0).applyQuaternion(thrustAngle);

  const scale = new Vector3(1, 1, 1).multiplyScalar(thrust / mass);

  const addition = new Vector3(0, GRAVITY, 0);

  const mult = new Vector3().multiplyVectors(vector, scale);

  const final = mult.add(addition);

  return final;


I think this is what you’re describing now.

What I’m sort of confused about though is how do I determine the proper initial vector? Here I’m using Vector3(0, 1, 0) because the y direction is “up”.

Also, I’m now trying to do this for angular rotation of all three axes because this rocket provides a thrust that can be angled which would impart a moment on the rocket in two of the rocket’s local axes.

So we know that for a single axis:
angularAcceleration = torque / momentOfInertia


torque = force * distance to center of gravity

And the force is the perpendicular force that can be found like:

force = totalForce * Math.cos(angle)

So that’s all well and good but when it comes to rotations in three dimensions, the force on an axis depends on a combination of two perpendicular components that come from the other two axes.

I have a quaternion which represents the rotation of the rocket body referenced to world space. And a quaternion that is made from euler angles to position the thrust I’m guessing in world space as well.

I’m not sure how to combine the rocket and thrust vectors to get the right forces.

In linear acceleration, I wanted all angles in world space because the acceleration is relative to the x,y and z axes of the world. But for rotation, I want the accelerations relative to rocket space because the rocket spins and it brings the rocket thruster along for the ride.

You will likely need to maintain local positional and rotational accelerations and, whenever you apply new acceleration, update the local ones accordingly (using similar change of space transformations).