Get the camera transformation matrix (Camera pose, not view matrix)

2.3k Views Asked by At

Let's say that I have an object and a camera (its representation) in a 3D world coordinate system. I have the camera pose to see the object (rotation matrix and translation (eye position)). If I apply a transform matrix to the object (a certain scaling/translation/rotation), what do I need to find the correct transform matrix that'll move my camera pose in order that what the camera sees remain unchanged (like it was before the transform was applied on the object)? I can't just apply the same transform as the object (it'll work for a translation, but rotation will cause to lose its target...). Also, a restriction that I have is that I can't apply transforms directly on the world, only on the object itself and on the camera itself (rotation/scaling/translation about the world coordinate system center).

Thanks to anyone that will takes time to help me! (Sorry for grammar errors, I speak French)

Marc-Antoine

2

There are 2 best solutions below

1
On BEST ANSWER

I'm on the right track now, I did as I've suggest earlier :

Should I apply the object's transform to the target point and to a given vector between the camera eye point and target point, then I'll get my new target and my new camera eye point (which is the end of my new vector)? Will that be enough information to setup the camera pose properly?

but I've also applied the transform to the up-vector of the camera to get it right. Result: for any kind of translation/rotation applied to the object the camera move properly (Yeah!). The only problem that remains is when I scale the object. If I shrink it, it gets smaller in the camera view after the transform is applied (and vice-versa).

4
On

I suspect your issue is that you're really thinking of rotating both the object and camera about their respective centers - this is not applying the same rotation, hence transformation, to each. If you do apply the same rotation (in the same plane, about the same point) and translation to each, this is an affine transformation, which

preserves points, straight lines and planes [...].

In particular, it will preserve the straight line connecting the camera to the object.

Take, for example, the wheel of a bicycle as it moves. A point on the rim is always 'facing' (and at a constant distance from) the axle, while constantly being subjected to rotations (about the axle) and translations (as the bicycle moves forward). In the camera setting, this reflects the fact that the same rotation about the object can be applied to both object and camera, while preserving the camera's view of the object.

The same can be said of the two endpoints of a spoke: the same linear transformation is applied to each endpoint, and the same spoke (line of sight) connects both endpoints, as the entire wheel is transformed. This rotation is not about either endpoint of the spoke, and still the same transformation applied to both preserves the spoke. This corresponds to a rotation about a point that is neither the camera nor object, along with a translation. Still the line of sight (spoke) is preserved.