What is the problem. I have a ship with subentities and want to know the absolute position of the subentity. For the mother I can get the position but for the subentity I get the relative position as defined in shipData.
Okay, no problem I though, next function should do the trick were position is the relative position of the subentity. Rotate the relative vector according to the orientation of the main ship.:
Code: Select all
this.localToGlobal = function(position)
{
return this.ship.position.add(position.rotateBy(this.ship.orientation));
}
Code: Select all
this.localToGlobal = function(position)
{
var orientation = this.ship.orientation
orientation.w = -orientation.w
return this.ship.position.add(position.rotateBy(orientation));
}
I noticed this function was added in oolite 1.70 (couldn't find it in 1.69) so it could be the normal game doesn't use it and therefor is never tested.