Matrix invert returns none in latest build?

Hi,

I was happily doing op(‘cam1’).worldTransform.invert() in build 1224x, now in 12710 it returns none, same for transpose() and identity().

I saw in the release notes
BACKWARDS COMPATIBILITY ISSUE - To avoid confusion; Matrix/Vector/Position objects no longer return a Matrix/Vector/Position unless it’s a new object, not a reference to themselves.

Not sure what this means and how to get invert() again?

Thanks!

The idea behind the change, and I’m open to discussion on it, was to avoid confusion like this:

m = op('cam1').worldTransform
mInvert = m.invert()
 # mInvert is just a reference to m, so they both hold the inverse worldTransform now

I found that looking at this code you may not expect m to also be inverted.

If you are in a script you can just split up your code to 2 lines. Get the worldTransform() and assign it to a variable, then call invert() on that variable. Does that work for you? Or are you doing this in a parameter, where I could see the previous behavior being desired, but maybe I should add a worldTransformInverse method.

Mmm reading the release notes I tried that before my initial post, trying it again, but still returns none in 12710.

this is what I’m doing :

m = op('cam1').worldTransform a = m.invert() print(a)

Thanks!

It will always return None now. You don’t need to assign something to m.invert() as m will contain the inverted matrix.

m = op('cam1').worldTransform
m.invert()
print(m) # m is now the invert

Ok, got it, sorry I’m a little slow today.
Makes sense, though it adds extra lines of code.
I was doing op(‘…/cam1’).worldTransform.invert()[x,y] to fill a dat table.

Indeed could be nice to have a getInverted() or getTransposed() that returns a inverted/tranposed copy, though I can live without it!

Best
Vincent

Oh and on a slightly related subject, it would be great to have a dedicated python search on the wiki.
For example if I search for matrix, I get the tscript expression
derivative.ca/wiki088/index.php?title=Matrix

same for time, I get derivative.ca/wiki088/index. … COMP_Class, same for realTime…

Thanks,
Vincent

Any news on that since I would actually benefit from doing

op('null1').worldTransform.invert()

in a parameter :slight_smile: ?

Or is there other ways to do it ?