## 4 Moving Head Calibration
### Determining the Moving Head Position
 \tag{13}\]  
Using the direct angle between \({}^{Ref}\vec{v}_{n}\) and \({}^{Ref}\vec{v}_{m}\) is not preferable in 3D space, as splitting it into two components equivalent to \(pan^{\circ}\) and \(tilt^{\circ}\) adequately functions. Therefore, if one component of the combined angle is much larger than the other, it conceals the other part. In order to reduce the complexity of this decomposition, the assumption is made that the \({}^{Ref}xy\) and \({}^{MH}xy\) planes are parallel or anti-parallel. This is due to the fact that rotations around three axes are indefinite, meaning that different solutions exist for the same change in orientation, precipitating unfavorable results and problems in the iteration. Since the workpiece is placed in a solid, alignable fixture, and the moving head can be easily aligned as well, the assumption can be considered valid. Therefore, both point pair vectors can be projected onto the \({}^{Ref}xy\) plane to obtain the \({}^{Ref}\vec{v}_{n}\) and \({}^{Ref}\vec{v}_{m}\) vectors in Equation (14), which are independent of \(tilt_{i}^{\circ}\) for \(tilt_{i}^{\circ}\in[0^{\circ},90^{\circ}[\). \[{}^{Ref}\vec{v}_{i}={}^{Ref}(\mathbf{P}\cdot\vec{v}_{i})={}^{Ref}\left( \begin{pmatrix} 1&0&0\\ 0&1&0\\ 0&0&0\end{pmatrix} \cdot \begin{pmatrix}x_{i}\\ y_{i}\\ z_{i}\end{pmatrix} \right)={}^{Ref} \begin{pmatrix}x_{i}\\ y_{i}\\ 0\end{pmatrix}  \tag{14}\]Therefore the angle between \({}^{Ref}\hat{\vec{v}}_{n}\) and \({}^{Ref}\hat{\vec{v}}_{m}\) can be equated to \(\Delta pan_{n,m}^{\circ}\) from Equation (11). Reshaping Equation (15) to a zero equation yields the first set of function equations (Equation (16)) for the iteration. \[\Delta pan_{n,m}^{\circ}\equiv arccos\left({}^{Ref}\left(\frac{\hat{\vec{v}}_{n }\cdot\hat{\vec{v}}_{m}}{||\hat{\vec{v}}_{n}||\cdot||\hat{\vec{v}}_{m}||}\right)\right) \tag{15}\]  
\[f_{I}:\qquad 0=arccos\left({}^{Ref}\left(\frac{\hat{\vec{v}}_{n}\cdot\hat{\vec{v}} _{m}}{||\hat{\vec{v}}_{n}||\cdot||\hat{\vec{v}}_{m}||}\right)\right)-\ \Delta pan_{n,m}^{\circ} \tag{16}\]  
For deriving the \(\Delta tilt_{n,m}^{\circ}\) angle, both vectors must be on a plane orthogonal to the \({}^{Ref}xy\) plane, which makes them independent of the \(\Delta pan_{n,m}^{\circ}\) angle. This condition can be satisfied by rotating the \({}^{Ref}\vec{v}_{m}\) vector around the \(z\) axis by \(-\Delta pan_{n,m}^{\circ}\), as shown in Figure 7 and Equation (17). In conjunction with the resulting vector \({}^{Ref}\hat{\vec{v}}_{m}\), the accompanying point \({}^{Ref}\vec{P}_{m}\) is rotated as well. Contrary to the simplified figure, the rotated point \({}^{Ref}\hat{\vec{P}}_{m}\) does not lie on the workplace surface anymore, as the length of the connecting vector did not change (\(||\hat{\vec{v}}_{m}||=||\vec{v}_{m}||\)). This does not have an impact on the further calculations, as only the angle between the vectors are relevant, and the vectors are normalized in Equation (18). \[{}^{Ref}\hat{\vec{v}}_{m}\overset{!}{=}\mathbf{R}_{z}(-\Delta pan_{n,m}^{\circ} )^{T}\cdot{}^{Ref}\vec{v}_{m} \tag{17}\]  
Analog to Equation (15) for \(\Delta pan_{n,m}^{\circ}\), Equation (18) is derived for \(\Delta tilt_{n,m}^{\circ}\). The second set of functions in Equation (19) for the iteration is then equivalent to Equation (16), now with the rotated second vector instead of the projected vector. \[\Delta tilt_{n,m}^{\circ}\equiv arccos\left({}^{Ref}\left(\frac{\vec{v}_{n} \cdot\hat{\vec{v}}_{m}}{||\vec{v}_{n}||\cdot||\hat{\vec{v}}_{m}||}\right)\right) \tag{18}\]  
\[f_{II}:\qquad 0=arccos\left({}^{Ref}\left(\frac{\vec{v}_{n}\cdot\hat{\vec{v}}_{m }}{||\vec{v}_{n}||\cdot||\hat{\vec{v}}_{m}||}\right)\right)-\ \Delta tilt_{n,m}^{\circ} \tag{19}\]  
With the two sets of function equations, Equations (16) and (19), the moving head position, which was defined and initialized in Equation (10), can be calculated iteratively.