# Using a rotation matrix to transform/shift a pinhole camera

I have a pinhole camera model with the following extrinsic (in Earth Centered, Earth Fixed Coordinate, (ECEF) system) and intrinsic parameters.

focal length (x,y) = 55000 px, optical center = (2400,540)

camera center (x,y,z), (ground coordinates) = -2322996.2171387854 -3875494.0767072071 5183320.6008059494 (ECEF)

Rotation matrix (3x3, camera to ground frame) = [[0.88982706839551795,-0.45517069374030594 ,0.032053516353234932], [-0.44472722029994571, -0.84940151315102252, 0.28413864394171567], [-0.10210527838913171, -0.26708932778514777, -0.95824725572701552]]

I need to shift the camera so that it points to the correct position on the ground based on a ECEF transformation matrix (4 X 4), which looks like this:

[[0.99999922456661872, 0.00043965959331068635, -0.0011651461883787318, 7033.5303197340108], [-0.00044011741039666426, 0.99999982604190574, -0.00039269946235032278 ,814.02427618065849], [0.0011649733316053631, 0.00039321195895935108, 0.99999924411047925 ,4139.9400998316705], [0, 0, 0, 1]]

The 3 x 3 matrix portion formed by the first three rows and columns are the rotation component, the first three values in the last column is the translation component. My general understanding is that I need to add the translation component to the camera center coordinates, while multiply the camera to ground rotation matrix with the rotation component. Is this sufficient, or would I need to do something extra ?

It looks like you got it, but what's actually going on here is that you are working in homogeneous coordinates.

In this system, a point in space is represented as a 4-tuple, $$(x,y,z,1)$$. You can multiply this 4-tuple by any non-zero constant and it represents the same point, so this is equivalent to $$(wx,wy,wz,w)$$ for any $$w \ne 0$$.

A vector is the difference between two points, and this is represented as a 4-tuple with a zero in the fourth component, $$(x,y,z,0)$$.

Right-multiplying that 4x4 matrix by a point has the effect of adding the translation component, and right-multiplying by a vector has the effect of not adding the translation component.

I think I got it. For transforming the camera-center, I use = rotation_component of transform*initial_camera_center + translation_component of transform.

For transforming the rotation-matrix, I use = rotation_component of transform*camera_rotation_matrix.

The camera is now in the correct place, looking in the right direction.