# python replacement for origin() function

i used this all the time in TScript-

derivative.ca/wiki088/index.php?title=Origin

but now I’m looking for a python alternative.

is there one?

There was not, but I just added relativeTransform() to the Object COMP class. It’ll be in the next Official release (13000+ series).

In the meantime though the math is pretty simple. If you want to know the transform to move geo1 to geo2, take both of their transforms, invert the one for geo1, and then multiply them together.

``````g1 = op('geo1')
g2 = op('geo2')
g1m = g1.worldTransform
g2m = g2.worldTransform
g1m.invert()
relT = g1m * g2m``````

hi malcom, can you just give me a hint, I guess my vector math has lots of issues but why don’t we have to use euklidean distance/pythagoras? Your suggestion seems a lot more simple+efficient, but I don’t get it.

It’s the magic of affine transformation math
To look at it one way, it’s just solving for X.
We have two transforms, A and B, we want to know X, which is the transform to move from A to B. Note: the order I’m putting these matrices is possibly wrong.
A * X = B
Multiply both side by AInverse
AInverse * A * X = AInverse * B
AInverse * A cancel each other out, so it becomes
X = AInverse * B

these black holes in math I constantly seem to trip over… en.wikipedia.org/wiki/Affine_spaces

thank you!

Perhaps as a temporary measure, it would be useful to have a pair of functions for evaluating TScript from Python (and maybe evaluating Python from TScript). It would help in cases where functionality from TScript hasn’t yet been ported over.

``me.parent.foo(tdu.tscriptEval("objdist('/foo/abc', '"+me.path + "', 'TX')"))``