## 4 Moving Head Calibration
### Determining the Moving Head Position  
After illuminating the reference points and saving their distinct \(pan\) and \(tilt\) values in the first phase of the calibration process, the projector position is to be calculated in the second phase. The general steps of this phase are shown in Figure 6 as well as the input data and the result of the calculation. Figure 5: Overall flowchart for the calibration process with the relevant subsections for the calculation steps. The sections related to the main steps are given in the brackets. The moving head's light beam does not have a depth sensor; therefore, the distance between the moving head and the workpiece is not directly known. Since the rotation of the moving head relative to the reference coordinate system is also not known, the absolute rotation values of the \(pan\) and \(tilt\) axes are not directly usable to calculate the moving head position. Therefore, the reference points are divided into \(\frac{N(N-1)}{2}\) duplicate free pairs, from which the angle differences \(\Delta pan\) and \(\Delta tilt\) between the two points of a pair can be calculated. These angle differences determine how far each axis has to move to get from one point to the other and no longer include the rotation of the moving head relative to the reference coordinate system. Furthermore, each point has a connecting vector in the reference coordinate system from the moving head to the reference point. The angle between these two vectors of each point pair can be decomposed into two angles that are equal to the \(\Delta pan\) and \(\Delta tilt\) angles from the moving head control. However, these vectors are not yet determined as the projector position is unknown, but they can be determined iteratively. The unknown projector position \({}^{Ref}\beta_{MH}\) in the reference coordinate system will be used as the iteration variables in the \(\vec{x}\) vector, as defined in Equation (10). The iteration variables can be considered as symbolic variables, so they can be used in the subsequent calculation without being known yet. \[{}^{Ref}\vec{P}_{MH}= \begin{matrix}{}^{Ref}\begin{pmatrix}x_{MH}\\ y_{MH}\\ z_{MH}\end{pmatrix}\equiv\vec{x}\end{matrix}  \tag{10}\]  
The initial value \(\vec{x}\)\({}^{(0)}\) should be chosen close to the actual projector position since the Euler angles allow for more than one solution that the iteration algorithm can converge to. The minimum requirement for this estimation is the need for the initial position to be placed on the correct side of the work piece. A second, non-optimal solution exists, which is mirrored with respect to a plane formed by the reference points. Any measurement that offers results in the cm range is usually sufficient for a fixed or repeating setup. Previously calculated positions can be used as well. An overview of the points, angles and vectors for the following calculations is given in Figure 7.  
Figure 6: Flowchart for determining the moving head position from the reference points relative to the reference coordinate system. The individual points in each point pair are index by \(n\) and \(m\), which satisfies the condition \(n,m\leq N\wedge n<m\), with \(N\) representing the total number of points. The angle differences in each point pair are calculated as shown in Equations (11) and (12). \[\Delta pan_{n,m}^{\circ}=pan_{m}^{\circ}-pan_{n}^{\circ} \tag{11}\]  
\[\Delta tilt_{n,m}^{\circ}=tilt_{m}^{\circ}-tilt_{n}^{\circ} \tag{12}\]  
The connecting vectors between each reference point and the moving head position are defined in Equation (13) with \(i=n,m\). For readability, the index \(i\) will be used when an equation applies to \(n\) and \(m\), and the \({}_{MH}\) subscript will be omitted. \[{}^{Ref}\vec{v}_{MH,i}={}^{Ref}(\vec{P}_{i}-\vec{P}_{MH})= \begin{pmatrix}{}^{ Ref}&\begin{pmatrix}x_{i}-x_{MH}\\ y_{i}-y_{MH}\\ z_{i}-z_{MH}\end{pmatrix}\stackrel{{!}}{{=}}{}^{Ref}\vec{v}_{i}\end{pmatrix}