Torque and signs and orbiter

jedidia

shoemaker without legs
Addon Developer
Joined
Mar 19, 2008
Messages
10,927
Reaction score
2,192
Points
203
Location
between the planets
I had some major problems figuring out the correct signs of my torque, and while everything is working now in all configurations, I don't get why. I'm still convinced that it shouldn't, and I want to understand where I'm wrong.

So here's the situation: In IMS2, I have to assign rcs thrusters to thruster groups programmatically, because I don't know where people will place them. The algorithm doing that works really well, but I noticed inconsistencies when starting to hook up my own autopilots. Namely, they all seem to point in the exactly wrong direction. Except when orbiter is using them, then they're perfectly fine.

THis led me to do some measurments with GetTorque() and compare them to my initial assumptions. The result: Those thrusters really should all be pointing in the wrong direction, but are obviously not. Here's how I arrived at that conclusion.

For the initial assignement, I'm calculating torque as t = pos X dir, where pos is the position of the thruster, and dir is the direction of force... I.e. the opposite of the direction the exhaust is pointing towards.

Then I assign the thrusters to various groups based on several computations, but of course one of the most important factors is whether the torque is positive or negative, and in which axis. And I decided this criteria not by numerical analysis, but by situational analysis and experimentation, because I suck at numbers.

So I knew that if a thruster was for example at pos 0 0 8 and dir 0 -1 0, the result of firing it would obviously be the vessel pitching down. So I calculated the torque of this setup, and the result just so happens to be positive around the x-axis.

and so on and so forth, this is how I set up the groups (the entire process is a lot more complicated and ivolves suitability scores for different group based on all axes and stuff, but this is the basic assumption I use).

That all worked really well, until I tried to implement some killrot autopilot code Hlynkacg was kind enough to lend me (because autopilots don't work so well with IMS2 anymore in the latest revision).

Here, of course, the basic assumption is to apply torque that goes contrary to angular velocity, which turned out to be the exact wrong way. And after a few experiments culminating in measuring torque directly with the API, I realised that indeed, negative torque was applied to the vessel when I pitched down.
Now please remember that I made a perfectly valid assumption above when assigning the groups, and the torque, purely numerically calculated, came up positive, and the groups the thrusters are assigned to are perfectly correct, as evident by orbiter being able to use them, and the correct thrusters firing when I engage stock autopilots.

So where am I wrong in this? Why does the torque of (0 0 8) X (0 -1 0) come up as (8 0 0), while the torque applied to the vessel is actually (-8 0 0) * thrust??

Also, why can't I find a way to explain this cleaner? I'm really sorry for the long post...
 
Last edited:

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,794
Reaction score
2,546
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
My first guestimate would be "left handed coordinate system"...
 

jedidia

shoemaker without legs
Addon Developer
Joined
Mar 19, 2008
Messages
10,927
Reaction score
2,192
Points
203
Location
between the planets
But if I use the crossproduct function provided by orbiter, shouldn't the result be correct in orbiters coordinate system?
Also, I was pretty much thinking left-handed when I made all my assumptions. Not saying that some right-handed thought might not have crept its way in, though
 

fred18

Addon Developer
Addon Developer
Donator
Joined
Feb 2, 2012
Messages
1,667
Reaction score
107
Points
78
I'm not sure you're right when you say that you're usinge the crossp "provided by orbiter". Cross product is cross product anyway. The vessel has a left handed coordinate system, how do you determine the sign? If you do the cross product between force and direction in your case you obtain a vector towards left, left is the positive x axis, so that's why.

I think that if you point your thrust left (1,0,0) you'll obtain a torque vector pointing up, and that's positive y axis.

Cross product is done with right hand, its result shall be considered in a left handed system with orbiter. So in your case, as said, the torque vector obtained by the cross p is towards left, and left is x positive.
To imagine cross p point all the fingers except the first one of your right hand in the direction of the first vector of crossp, then close them in the direction of the second vector of the crossp, the direction you obtain with your first finger is the direction of the result

---------- Post added at 08:40 ---------- Previous post was at 08:32 ----------

That's what i mean:

[ame="http://youtu.be/zGyfiOqiR4s"]http://youtu.be/zGyfiOqiR4s[/ame]
 

jedidia

shoemaker without legs
Addon Developer
Joined
Mar 19, 2008
Messages
10,927
Reaction score
2,192
Points
203
Location
between the planets
Thanks a lot!
I had looked at very similar videos, and they seem clear enough, until I try to get numbers in there. Frankly, I was very confused about whether into the page and out of the page represented plus or minus, because noone ever said. In other words, when looking at the page, am I facing along the axis, or down the axis?
This video was a tiny bit different from others, and that tiny bit was enough to make me realise that the page does not really represent the plane, but the coordinate system.

In other words, if it's a right-handed coordinate system, x+ is to the right, y+ is up, and z+ is in my face.
But if it's a left-handed system, x+ and y+ are still to the right and up, but z+ is in the opposite direction. In other words, if I do the example as shown in the video, the thumb is indeed pointing z- in a right-handed system, but z+ in a left-handed system. And it turns out like this for all the other axes, too!

I guess my biggest problem always was that I was thinking of torque direction as relative rotational direction, i.e. in my mind positive meant "counter-clockwise around the axis of rotation when facing along it". I now realise that it's a purely abstract property that can only be interpreted when you know the coordinate system being used (like any direction, come to think of it...).
 
Last edited:
Top