I'm solving a linear equation to find a transformation (an homography) from (xi,yi) to (ui,vi) (i=1,2,3,4) :
$$ui = \frac{c00*xi + c01*yi + c02}{c20*xi + c21*yi + c22}$$
$$vi = \frac{c10*xi + c11*yi + c12}{c20*xi + c21*yi + c22}$$
The coefficients cij are calculated by solving linear system using gaussian elimination with the optimal pivot element chosen:
$$\left[ \begin{array}{c} u0 \\ u1 \\u2 \\u3 \\v0 \\v1 \\v2 \\v3 \end{array} \right] = \begin{bmatrix} x0 & y0 & 1 & 0 & 0 & 0 & -x0*u0 & -y0*u0 \\ x1 & y1 & 1 & 0 & 0 & 0 & -x1*u1 & -y1*u1 \\ x2 & y2 & 1 & 0 & 0 & 0 & -x2*u2 & -y2*u2 \\ x3 & y3 & 1 & 0 & 0 & 0 & -x3*u3 & -y3*u3 \\ 0 & 0 & 0 & x0 & y0 & 1 & -x0*v0 & -y0*v0 \\ 0 & 0 & 0 & x1 & y1 & 1 & -x1*v1 & -y1*v1 \\ 0 & 0 & 0 & x2 & y2 & 1 & -x2*v2 & -y2*v2 \\ 0 & 0 & 0 & x3 & y3 & 1 & -x3*v3 & -y3*v3 \\ \end{bmatrix} \times \left[ \begin{array}{c} c00 \\ c01 \\ c02 \\ c10 \\ c11 \\ c12 \\ c20 \\ c21 \\ \end{array} \right]$$
And c22 = 1
Now what I want to do is to work with spherical cartesian coordinates. So instead of having (xi,yi) and (ui,vi), I'll have (xi,yi,zi) and (ui,vi,wi) both on two units spheres Sx and Su respectively. I'll have four points on each sphere and I want to compute the homography between those.
I've two questions:
Can I use the same arrangement in the case of my new coordinates?
How the last two colums are made ?
I believe that the algorithm you should look at is called Direct Linear Transformation (Hartley CVPR 1999 or Chapter 4.1 Direct Linear Transformation in [1]).
The idea is simple enough. For if you express your solution as $(u_i, v_i,1)^\top$ you have a set of homogeneous equations of the like of
$(u_i, v_i,1)^\top\propto\mathbf{H}(x_i,y_i,1)^\top$
where $\mathbf{H}$ is a homogeneous $3\times3 $ matrix. The right and left side are linearly dependent three-vectors. Their cross-product will be zero.
$0=(u_i, v_i,1)^\top \times \mathbf{H}(x_i,y_i,1)^\top$
This can be neatly re-arranged and solved via SVD or QR.
As for the spherical v.s. projective space, see https://en.wikipedia.org/wiki/Projective_space In essence, if you allow homogeneous vectors to be signed (i.e. up to positive scale only), you have the same topology as the sphere.
[1] Hartley, Richard, and Andrew Zisserman. Multiple view geometry in computer vision. Cambridge university press, 2003.