# Transform plane to another coordinate system

I have a camera coordinate system defined by rotation matrix $R$ and translation $T$ with respect to the world coordinate system. A plane is defined in the camera coordinate by the normal $N$ and point $P$ on it. I want to find the equation of the plane in the world coordinate system. Currently I'm doing it is:

Transform $P$ to world system by $(P + T)$

Transform $N$ to world system by $R * N$

Then I'm finding the equation of the plan using the transformed $P$ and $N$. I have two questions:

1) If we take the perpendicular distance of the camera center to the plane in camera coordinate system, that should be equal to the perpendicular distance of camera location to plane in world coordinate system, right ?

2) Assuming the above is true, my current transformation is giving incorrect results for example plane of $N=[1,2,1]$ and $P=[1,4,0]$ (in camera) and $R = \left( \begin{smallmatrix} 0&-1&0\\ 0&0&-1\\ 1&0&0 \end{smallmatrix} \right)$ and $T =[3, 3, 9]$

Am I doing something wrong ? Thanks

• Your example of $R$ is not a matrix, and it's not clear why you need "." in the formula for applying a rotation matrix to a vector. Otherwise the approach seems OK, so perhaps the error is in the calculations or in your interpretation of the results. Since you have shown none of those things it is hard to say what's wrong. You could edit your calculations and results into the question; maybe that will help. – David K Nov 3 '17 at 12:58
• See math.stackexchange.com/help/notation about writing formulas. – David K Nov 3 '17 at 12:59
• No I converted the euler notation to a 3x3 rotation matrix which I'm denoting by R. That's what I'm multiplying with N. It's not a dot product but a matrix multiplication. I'll edit to make the changes – bluechill Nov 3 '17 at 13:06
• I'm not very familiar with how one model the camera system coordinate wrt the world coordinate, but shouldn't $R$ be taken into account when converting from camera coordinates to world coordinates for point $P$? If $R$ has no impact, then that would mean the $XYZ$-axes of the camera coordinates are aligned with the $XYZ$-axes of the world coordinate? – N.Bach Nov 3 '17 at 13:09
• @N.Bach I think you are right. I should also transform the point with rotation as well. That might fix it I think. – bluechill Nov 3 '17 at 13:10

Working in homogeneous coordinates, the Cartesian equation $ax+by+cz+d=0$ can be expressed as $\mathbf\pi^T\mathbf X=0$, where the homogeneous vector $\mathbf\pi=[a:b:c:d]$. If $\mathtt M$ is a nonsingular transformation matrix, then $$\mathbf\pi^T\mathbf X=\mathbf\pi^T\mathtt M^{-1}\mathtt M\mathbf X=(\mathtt M^{-T}\mathbf\pi)^T(\mathtt M\mathbf X) = 0,$$ which shows that the vectors that represent planes are covariant: if points transform as $\mathbf X'=\mathtt M\mathbf X$, then planes transform as $\mathbf\pi'=\mathtt M^{-T}\mathbf\pi$.
In your case, the equation of the plane in camera coordinates is given by the point-normal form $\mathbf N\cdot(\mathbf X-\mathbf P)=0$, so we have $\mathbf\pi_C=[\mathbf N^T;-\mathbf N^T\mathbf P]^T$. We have for the world-to-camera mapping the matrix $\mathtt M = \left[\begin{array}{c|c}\mathtt R & \mathbf T\end{array}\right]$ and so camera-coordinate planes are transformed into world coordinates by $(\mathtt M^{-1})^{-T} = \mathtt M^T$, i.e., $$\mathbf\pi_W = \mathtt M^T\mathbf\pi_C = \left[\begin{array}{c|c} \mathtt R^T & \mathbf 0 \\ \hline \mathbf T^T & 1\end{array}\right]\begin{bmatrix} \mathbf N \\ -\mathbf N^T \mathbf P\end{bmatrix} = \begin{bmatrix} \mathtt R^T \mathbf N \\ \mathbf N^T\mathbf T-\mathbf N^T\mathbf P \end{bmatrix}.$$
For your example, $\mathbf\pi_C = [1,2,1,-9]^T$ and $$\mathbf\pi_W = \left[\begin{array}{r}0&0&1&0\\-1&0&0&0\\0&-1&0&0\\3&3&9&1\end{array}\right]\left[\begin{array}{r}1\\2\\1\\-9\end{array}\right] = \left[\begin{array}{r}1\\-1\\-2\\9\end{array}\right]$$ and so the equation of the plane in world coordinates is $x-y-2z+9=0$.
Using your approach, transform $\mathbf P_C$ to world coordinates: $$\mathbf P_W = \left[\begin{array}{c|c} \mathtt R^T & -\mathtt R^T\mathbf T \end{array}\right] \begin{bmatrix}\mathbf P_C\\1\end{bmatrix} = \left[\begin{array}{r}0&0&1&-9\\-1&0&0&3\\0&-1&0&3\end{array}\right]\begin{bmatrix}1\\4\\0\\1\end{bmatrix} = \left[\begin{array}{r}-9\\2\\-1\end{array}\right].$$ Compared to what you described in your question, it looks like you only translated $\mathbf P_C$, but to convert to world coordinates it must be both translated and rotated. Normal vectors are covariant, so $$\mathbf N_W = (\mathtt R^{-1})^{-T}\mathbf N_C = \mathtt R^T\mathbf N_C = \left[\begin{array}{r}0&0&1\\-1&0&0\\0&-1&0\end{array}\right]\begin{bmatrix}1\\2\\1\end{bmatrix} = \left[\begin{array}{r}1\\-1\\-2\end{array}\right],$$ giving for the world-coordinate equation of the plane $$(1,-1,2)\cdot(x+9,y-2,z+1)=x-y-2z+9=0$$ as above. Comparing this to your calculation, you transformed the normal vector incorrectly as well.
We can check distances, as you suggest: The distance of the plane from the camera (camera-coordinate origin) is $${[1,2,1]\cdot[1,4,0]\over\|[1,2,1]\|} = {9\over\sqrt6}.$$ The world coordinates of the camera are the last column of the camera-to-world matrix, and the world-coordinate distance of this point from the plane is $${|[1,-1,-2]\cdot[-9,3,3]+9|\over\|[1,-1,-2]\|} = {9\over\sqrt6}.$$ You can also check that this is indeed the correct plane by transforming a few points on it to world coordinates and then plugging those coordinates into its world-coordinate equation.