# Fast 3D Analytical Affine Transformation for Polygon-Based Computer-Generated Holograms
## 3 Theory
The accurate method is to avoid the use of pseudo matrices and to find the affine transformation matrix \(T\) through direct calculation of \(T=GA^{-1}\). There are twelve unknown elements in affine matrix \(T\), and so we have to solve twelve equations to get these twelve elements. However, each matrix \(G\) and \(A\) only contain three vertexes in Equation (6). From this, we can only get nine equations to solve for the nine elements; the remaining elements in the affine matrix \(T\) cannot be determined. In light of this, we introduce a new set of vertexes \(\left(s_{4},t_{4},p_{4}\right)^{t}\) in matrix \(A\) and a \(4\times 1\) vector \(\left[d_{1},d_{2},d_{3},d_{4}\right]^{t}\) in matrix \(G\) to determine all the unknown twelve elements of the affine matrix \(T\). Therefore, we extend \(G\) and \(A\) to a \(4\times 4\) matrix \(G_{1}\) and \(A_{1}\), respectively. In light of this, Equation (6) becomes:  
\[G_{1}= \begin{bmatrix}x_{1}&x_{2}&x_{3}&d_{1}\\ y_{1}&y_{2}&y_{3}&d_{2}\\ z_{1}&z_{2}&z_{3}&d_{3}\\ 1&1&1&d_{4}\end{bmatrix} =TA_{1}= \begin{bmatrix}r_{11}&r_{12}&r_{13}&c_{1}\\ r_{21}&r_{22}&r_{23}&c_{2}\\ r_{31}&r_{22}&r_{33}&c_{3}\\ 0&0&0&1\end{bmatrix}\begin{bmatrix}s_{1}&s_{2}&s_{3}&s_{4}\\ t_{1}&t_{2}&t_{3}&t_{4}\\ p_{1}&p_{2}&p_{3}&p_{4}\\ 1&1&1&d_{4}\end{bmatrix} . \tag{7}\]  
In order to simplify calculations and improve the calculation efficiency, the best choice is let \(d_{1}=d_{2}=d_{3}=d_{4}=0\) and \(\left(s_{4},t_{4},p_{4}\right)=\left(0,0,1\right)\). Then, \(A_{1}\) becomes  
\[A_{1}= \begin{bmatrix}0&1&0&0\\ 0&0&1&0\\ 0&0&0&1\\ 1&1&1&0\end{bmatrix} . \tag{8}\]  
Through simple calculations, we can obtain \(\det(A_{1})=-1\), indicating the existence of the inverse matrix of \(A_{1}\). Then, we can find the affine transformation matrix \(T\) by \(T=G_{1}{A_{1}}^{-1}\). Note that the vertex \(\left(s_{4},t_{4},p_{4}\right)^{t}\) only represents a point located in the primitive coordinate system independent of the primitive triangle, and the value of \(\left(s_{4},t_{4},p_{4}\right)^{t}\) and \(d_{4}\) must be chosen such that \(\det(A_{1})\
eq 0\) to make sure the inverse of \(A_{1}\) exists. \(d_{1\sim 3}\) can take any value; different values of \(d_{1\sim 3}\) make a different affine transformation matrix \(T\) and the Jacobian determinant also changes at the same time. Again, we have chosen Equation (8) for ease of calculations and there is no effect on the final results that we end up solving. According to the above discussion, the affine transformation matrix \(T\) can be obtained by Equation (7):  
\[T=G_{1}{A_{1}}^{-1}= \begin{bmatrix}-x_{1}+x_{2}&-x_{1}+x_{3}&0&x_{1}\\ -y_{1}+y_{2}&-y_{1}+y_{3}&0&y_{1}\\ -z_{1}+z_{2}&-z_{1}+z_{3}&0&z_{1}\\ 0&0&0&1\end{bmatrix} . \tag{9}\]  
For primitive triangle \(\Delta\), assuming that its surface function has strength of one within the triangle and zero outside, its spectrum analytical expression \(F_{\Delta}(u_{s},v_{t})\) can be obtained (see Appendix A):  
\[F_{\Delta}(u_{s},v_{t})=\iint_{\Delta}1\cdot e^{-2\pi(u_{s}s+v_{t}t)}dsdt\] \[=\frac{1}{2\pi^{2}}\bigg{[}\frac{\e^{-j2\pi v_{t}}}{(u_{s}-v_{t}) \cdot v_{t}}-\frac{\e^{-j2\pi u_{s}}}{(u_{s}-v_{t})\cdot u_{s}}-\frac{1}{u_{s} \cdot v_{t}}\bigg{]}, \tag{10}\]where \(u_{s},v_{t}\) are the spatial frequencies corresponding to affine coordinates \(s\) and \(t\). The singular points \(u_{s}=0\), \(v_{t}=0\) or \(u_{s}-v_{t}=0\) have been discussed in Appendix A. Through affine transformation, the spectrum distribution of tilted triangle \(\Pi\) on the hologram plane is (see the derivation of this equation in Appendix B):  
\[ \begin{split}& F_{HOLO}(u,v){=}\iint_{\Pi}f\left(\overset{\rightarrow} {r_{g}}\right)\cdot\mathrm{e}^{-j2\pi(ux+vy+wz)}dxdy\\ &\quad=\iint_{\Delta}f(\overset{\rightarrow}{Rr_{a}}+\overset{ \rightarrow}{C})\cdot\mathrm{e}^{-j2\pi(ux+vy+wz)}\cdot J\cdot dsdt,\end{split}