Determining Lever arm in 3 Dimensions

Hlynkacg

Aspiring rocket scientist
Addon Developer
Tutorial Publisher
Donator
Joined
Dec 27, 2010
Messages
1,868
Reaction score
4
Points
0
Location
San Diego
So i've been working on a thruster control program and I need to determine the torque induced by a given thruster.

Now the standard way to calculate the magnitude of a torque input is to determine the length of the lever arm and then multiply by the applied force. Where the lever arm is the perpendicular distance from the axis of rotation to the line of action of the force.

To this end I wrote the following code...

Code:
	// Torque
	output.T.x = output.pos.x * output.F.x;
	output.T.y = output.pos.y * output.F.y;
	output.T.z = output.pos.z * output.F.z;

where T is the torque vector F is force and pos is the thruster's reference point.

I know that this is wrong.

So how do I calculate torque lever arm in 3 dimensions?
 
The [ame="http://en.wikipedia.org/wiki/Torque"]wiki article on torque[/ame] should give you all necessary info.

Torque (in 3D) is the cross product of the position vector with the force vector. Assuming then that the position vector of the thruster (relative to the center of mass) is {rx, ry, rz}, and the force of the thruster is {fx, fy, fz}, then the torque (at the center of mass) {tx, ty, tz} is

tx = ry*fz - rz*fy
ty = rz*fx - rx*fz
tz = rx*fy - ry*fx

Your code, btw, seems to do a componentwise multiplication of the position and force vectors. That is not the torque, alas.

PS: if you want torque around some point R (not necessarily the center of mass) then just replace the {rx, ry, rz} from above with whatever position vector the thruster has relative to R.
 
so...

Code:
	output.T.x = (output.pos.y * output.F.z) - (output.pos.z * output.F.y);
	output.T.y = (output.pos.z * output.F.x) - (output.pos.x * output.F.z);
	output.T.z = (output.pos.x * output.F.y) - (output.pos.y * output.F.x);
?

Your code, btw, seems to do a componentwise multiplication of the position and force vectors. That is not the torque, alas.

Well yes it does, but then my results failed to pass sanity check. :facepalm:
 
so...

Code:
	output.T.x = (output.pos.y * output.F.z) - (output.pos.z * output.F.y);
	output.T.y = (output.pos.z * output.F.x) - (output.pos.x * output.F.z);
	output.T.z = (output.pos.x * output.F.y) - (output.pos.y * output.F.x);
?

That looks right.
 
Thank you, that was really bugging me.
 
You can also just use

Code:
torque = crossp(radius, force);

if you want to avoid doing all that math yourself.
 
You can also just use

Code:
torque = crossp(radius, force);

if you want to avoid doing all that math yourself.

is "radius" in torque = crossp(radius, force); the position vector?
 
is "radius" in torque = crossp(radius, force); the position vector?

Yes. (Relative to the point you want to know about)
The math you did above exactly implements this cross product. It just would save lines of code to use the function that already exists to do this.
 
Last edited:
Back
Top