World to local rotation of an object

Hi guys,

I have the following question

Suppose I have the Pose of an object (translation and rotational information) but with respect to the camera frame (it’s a perspective camera). I believe this is the world coordinates but someone might correct me

What I would like to know is the rotation of the object but in it’s local pose coordinate system, (not relative to the camera, but a local rotation to the object itself - I don’t really care about translation)

I know the camera intrinsic data. How would I go about getting the local rotation?

Hope this makes sense

Thanks

The structure of your scene depends here. Lets say you have a scene with a camera and a object. Then the objects local transform would be equal to its world transform because its not nested.
If you have a scene with a group of spheres nested inside a container obj. Then the spheres transform are local to its parent container, and world to the scene.

scene.position.set(0, 0, 0) // this is default
container.position.set(5, 0, 0) // offset container x = 5 from scene center
sphere.position.set(3, 0, 0) // sphere is offseted x = 3 from the center of container, means x = 8 away from scene center

If you want to get the local transform of your obj just use: obj.position, obj.rotation, obj.scale, which is always the local transform
If you want to get the world transform of your obj, use obj.getWorldQuaternion(targetQ), obj.getWorldPosition(targetV3), obj.getWorldScale(targetV3)

Here is a fiddle

1 Like

Thanks for the reply

So what I am trying to do is mimic a real world setup. I have a camera that is capable of getting pose of an object in the image. What I would like to do is prove that the returned pose is correct by placing the object in a known local pose and compare against what theoretical functions return back in threejs in a virtual environment

At the moment the returned pose is relative to the camera frame and not in local coordinates and so I need a way of converting between the two

So can I do the following in threejs to mimic the setup virtually

  1. Set up a perspective camera with my intrinsic camera parameters in threejs ( can it take all the intrinsic information like focal length, sensor center cx, cy etc
  2. Set the 3D pose of an object in threejs with respect to the camera - not the local object system (not sure how I set this part up)
  3. Read back the local rotation of object looks like I can just use obj.rotation()

Again I hope this makes sense

Im not fully understanding what youre going for, but to be clear, the camera has no impact on the objs itself or the scene in any way. The camera is just another obj floating through space observing the scene in its current state from its (camera) current transformation (position, rotation).

Can you relate what you are trying to achieve? I guess you have a certain transformation that you wanna check for? Maybe youd wanna look into matrices. Position, Rotation and Scale are stored in a transformation matrix. These matrices can be added or multiplied etc to achieve rotation and translation and can probably be compared as well.

OK I’ll try and explain better

  1. I have a pose of an object in the real world but it is in reference to the camera world coordinates
  2. I know the rotation of the object in the real world but only in the local coordinate system
  3. I need to check this pose rotation by converting it from world to local rotation so that I can compare it to my local known pose
  4. I was hoping I could use threejs to take the pose I got in the real world and translate it to a local pose for rotation only so I can compare

Does all that make sense?

Possibly need to use the matrices functions. I’m just not sure how to best I go about this. Any ideas on the best approach?

Thanks