Transforming between coordinate systems

Il trying to use touch for a sort of AR application. If I know an object’s 3d transform in a coordinate system with respect to a camera, how can I translate it into a transpform within a different coordinate syatem? My approach was to move the physical object to the origin of
My world and then save it its transform in a null. I then take that Null and extract its transformation matrix in Python. I find the inverse of that matrix and multiply it by all updated transpforms as they come in. I was hoping this would enable me to determine things like rotation about the original saved null, but it doesn’t seem to work. Is this the right approach or am I totally off base?

Thanks,
Michael

Lets say you have camera C in your project and geometry G. Inside G there is a single vertex V. To get the position of V relative to C (such that C is considered to be at (0,0,0) looking down -Z), the equation is
CInverse * G * V

So I think you are on the right track. If you can post your math we can look closer at it.

Good to know I’m not totally off base, but I should clarify what I’m doing… I have a real-world camera performing object tracking. It’s telling me the position and rotation with respect to the real-world camera. I place my physical object at what I’ve defined as my real-world origin, with rotation (0,0,0). I then record the values I’m receiving (translation and rotation) with a record CHOP. I’d like to define that position as my new origin. I do this by executing the following code:

m = op(‘o’).worldTransform # o is the null that contains the recorded origin I want to define
m.invert()

a = op(‘incoming’).worldTransform #incoming is a null with live data coming to it

b = a * m

op(‘geo’).setTransform(b) #geo is the piece of geometry that corresponds to the real-world object I’m tracking

When this starts executing, it does have the effect of positioning the geometry at 0,0,0 with a rotation of 0,0,0. The problem is that it seems to not really transform correctly when I start moving my object around. The problem could potentially be in my input data, but I’d like to make sure I’m thinking about this correctly on the output side.

Thanks!
Michael

One thing to make sure is that the transform you are getting follows the conventions that TD uses with +Y up, +X right and +Z backward. These are arbitrary and many things use conventions such as +Y is down or +Z is forward.

Thanks! I think I can essentially also do this with an Object CHOP.