Spherical transformation from world coordinates

70 Views Asked by At

I have a camera pose (position and orientation) in a 'world coordinate' frame described by a (4, 4) transformation matrix.

I want to transform this in a spherical coordinate frame, assuming the original camera pose is located on a sphere of radius $r$ and oriented pointing at the centre of the sphere.

The transform I want to make is an elevation change (x axis) and an azimuth change (y axis) but keeping the camera pointing at the spheres centre.

What transformation matrix can achieve this by returning a new pose in the world coordinate frame?

Context

I am building a machine learning model to predict elevation and azimuth for the pose of an object in an image. Rather than allowing the model to perform any transformation I want to limit it to a camera transform on the sphere described above. I therefore need to formulate that transform to put into the forward part of the model.

I feel like I have the translation correct I'm just not sure about the rotation to continue having the camera pointing at the spheres origin (spheres centre).

Current attempt

Given an elevation change of $x$ radians, azimuth change of $y$ radians, and a $z$ change of 0 from the new spherical reference frame what is the new pose in the 'world' reference frame? Using the 'right-hand rule' with z positive away from the direction the camera is facing and using the 'right-hand grip rule'.

$$ original\_camera\_pose = \begin{bmatrix} 0.1674 & 0.3973 & -0.9023 & -0.9895 \\ -0.0821 & 0.9177 & 0.3888 & -0.3186 \\ 0.9825 & 0.0090 & 0.1862 & 0.9114 \\ 0.0000 & 0.0000 & 0.0000 & 1.0000 \\ \end{bmatrix} $$

$$ \begin{align} r & = 0.8 \\ c1 & = \cos(-x) \\ s1 & = \sin(-x) \\ c2 & = \cos(y) \\ s2 & = \sin(y) \\ c3 & = \cos(z) \\ s3 & = \sin(z) \\ x\_polar & = (\pi / 2) - x \\ x\_translation & = r * \sin(x\_polar) * \sin(y) \\ y\_translation & = r * \cos(x\_polar) \\ z\_translation & = r * \sin(x\_polar) * \cos(y) \\ \end{align} $$

$$ transform = \begin{bmatrix} c2 & s2s3 & c3s2 & x\_translation\\ s1s2 & c1c3 - c2s1s3 & -c1s3 - c2c3s1 & y\_translation \\ -c1s2 & c3s1 + c1c2s3 & c1c2c3 - s1s3 & z\_translation \\ 0 & 0 & 0 & 1 \\ \end{bmatrix} $$

$$ new\_camera\_pose = original\_camera\_pose * transform $$