Subtracting one orientation from another

im am trying to make a kind of compess thing, in a game, to point the player where to go. got the overlay all figured out if i can subtract the players z axis orientation from the compesses. im using 2.49 because some of my scripts are 2.49 scripts and i don’t want tos start over. here is what i have

controller = GameLogic.getCurrentController()
p1 = controller.getOwner()
Slist = GameLogic.getSceneList()
Game = Slist[0] 
p2 = Game.getObjectList()["OBArrow"]
p3 = Game.getObjectList()["OBp1"]
p2rot = p2.worldOrientation
p3rot = p3.worldOrientation

I wan’t to subtract p2rot from p3rot on just the z axis.

i don’t realy understand how the orientation works. ive tried converting to euler but it has not worked. can someone explain to me how the orientation lists work. Why do they need 9 numbers? what are they used for? is there a way to single out just the z axis?

That is actually a pretty big question. The reason there are 9 numbers is because those 9 numbers form a 3x3 matrix. That matrix is a mathematical concept that can encode an arbitrary 3d rotation or scaling of your object. I’m not sure what the API in 2.49 looks like but in 2.5+ you can access an objects “euler rotation”. If you can get to this then the this will be a vector and the “z” coordinate will have the rotation angle that you want to access.

There might be some function built-in function that will convert your ‘worldOrientation’ matrix to an “euler” or “euler vector”, you might investigate that as well.

I’m sorry I cannot be more specific, I started using Blender with 2.5+ so I don’t know what 2.49’s capabilities are.