invert matrix data?

In blender 2.49 I want to invert the orientation matrix of a gameobject. NOT reverse the order of data in the list. I want to invert each set of data in the orientation matrix like
obj.orientation[0, 1, 2] = obj.orientation[-0, -1, -2]
but I dont know the proper syntax. How do I do this?

If you want the opposite rotation, then the inverted attribute should suffice:
matrix.inverted()

so do i invert it like

orientation = obj.orientation.inverted() ?

so do i invert it like

orientation = obj.orientation.inverted() ?

Sound about right.

Hi
do you mean

you have [0,1,2] and want to have [0,-1,-2] ?
If yes, invert won’t work
you can do :

a=[3,0,1,2]
b=[-a[i] for i in range(len(a))]

invert would work like that :

a=Matrix(((1.0, -0.0, 0.0, 0.0),
        (0.0, 1.0, -0.0, 0.0),
        (-0.0, -0.0, 1.0, -0.0),
        (0.0, 0.0, -0.0, 5.0)))
a.invert()

a becomes

Matrix(((1.0, -0.0, 0.0, 0.0),
        (0.0, 1.0, -0.0, 0.0),
        (-0.0, -0.0, 1.0, -0.0),
        (0.0, 0.0, -0.0, 0.20000000298023224)))

Please be aware

Matrix.invert() operates on the given matrix.
Matrix.inverted() returns a separate result = new matrix

BTW. inverting a matrix does not mean you set all terms negative. It is a complex process and not always possible. Luckily transformation matrices for 3D geometry usually fulfill the requirements and are invertable.

The real question is: What do you want to achieve?

Well, when my player is moving forward with his jetpack, he uses the trackTo() to point in the direction that he is moving (turning is done with MouseLook.py). So when I angle the camera downward, the player starts to angle in the downward direction like it is supposed to. But when I reach a certain angle, the player does a 180 degree flip and ends up facing backwards. So basically I want to counter it with some kind of an invert orientation script. ive been working on the script but I still dont know how to set it up. It seems that there is no “obj.orientation.invert()” in the blender 2.49 API. If anyone knows a correctly syntaxed script or knows another way to counter my player from fliping, please, enlighten me.

2.49 provides lists of lists rather than Matrix classes. You can use the list of lists to create a Matrix from Mathutils (which is not the same as mathutils from 2.5+). This Matrix can be inverted as well.

As I said, inverting does not mean flipping directions as you want to get.

If you want to turn 180° it is a rotation around 180°. You need to tell which axis to turn around.
For example:
180° around X and
180° around Z are not the same!

The flipping happens when your orientation reaches the maximum “up-down” angle of 90°. Which means it looks straight downwards. In this situation the up axis (usually Z) matches the view axis. The “rolling” becomes ambiguous.

When you exceed the maximum angle of 90° degree the rolling becomes unique again. The up-vector tells where up is (Z-Axis) forcing the camera perform a 180° turn to ensure the up-vector is where it should be. Otherwise your camera would show an up-site down view.

The simplest way to solve that is to ensure the camera does not exceed a certain “up-down” angle.

It is a bit hard to give much better advice as this strongly depends on your situation. You described it pretty much, but I think I would need to see whats going on (I’m a bit a “visual” thinker :wink: ).

sorry for the late reply. I almost have a method for fixing my problem. My latest question is…how do I change the “tracking axis” of an object with python instead of changing it under ANIMATION SETTINGS in the GUI?