# Primitive Shape Fitting in Point Clouds Using the Bees Algorithm
## 4 Experimental Method
### Error Evaluation Function  
The best scoring solution \(F\) found by an algorithm in a \(PC\) (i.e., the found shape) is compared with the real shape \(I\), namely the reference shape used to generate said \(PC\). A fair evaluation of the solutions needs to take into account several issues. First, it involves the comparison of parameters of mixed units (angle degrees for orientation, linear units for size and position), and thus standard metrics (e.g., Euclidean distance) would not be appropriate. Second, differences in the centre or orientation have a larger impact on the matching of the two shapes (and hence on robotic manipulation) than a comparable offset in the size parameters. Finally, the data sets include shapes with differences in size up to one order of magnitude, and the evaluation function should be invariant to size. The error evaluation function considers the match and alignment of the three segments corresponding to the height, width, and depth of the \(F\) and \(I\) shapes. Each of the three segments is placed along one of the principal axes of symmetry of the shape (Figure 3). In the case of the box, the lengths of the three segments correspond to the three size parameters of the solution, in case of the cylinder the length of one segment corresponds to the height and the other two to the diameter of the circular section, in case of the sphere they are all equal to the diameter. If the principal axes are not unique (e.g., the three axes of the sphere), they are aligned with the Cartesian axes of the reference frame. The error is measured from the overlap between the projection of each segment of \(F\) onto the three segments of \(I\). In case of perfect matching and alignment, each segment of \(F\) (e.g., the height of a box)  
Figure 3: The found shape \(F\) is compared to the real shape \(I\) projecting its height, depth, and width onto the height, depth, and width of the real shape. will project exactly onto the corresponding segment of \(I\), and on a point (i.e., zero overlapping) onto the other two segments (the width and depth) of \(I\). In case of misalignment or incorrect dimensions of \(F\), the projection of one segment (e.g., the height of a box) will not cover exactly the corresponding segment (the height) of \(I\) (Figure 3(a)), and will be non-zero on the other two segments (the width and depth). Given a solution \(F\), let us denote as \(F^{1},F^{2}\) and \(F^{3}\) its three segments (the width, depth, and height respectively), sorted in decreasing order of length, and as \(\hat{F}^{i}_{j}\) the projection of the \(i^{th}\) segment of \(F\) on the \(j^{th}\) Cartesian axis, where \(j=1\) denotes the \(X\) axis, \(j=2\) denotes the \(Y\) axis, and \(j=3\) denotes the \(Z\) axis. Likewise, for the three axes of \(I\). Finally, let us denote henceforth as \(|A|\) the length of a given segment A. To simplify the calculations, a rigid transformation is applied to express \(F\) and \(I\) in a new Cartesian frame that corresponds to the three principal axes of \(I\). Note that now \(|\hat{I}^{i}_{i}|=|I^{i}|\) and \(|\hat{I}^{i}_{k}|=0\)\(\forall k\
eq i\) The error \(Err(F,I)\) in the alignment and match of \(F\) to \(I\) is calculated as follows:  
\[Err(F,I)=\min_{i=\{1,2,3\}}\left\{\min_{ \begin{subarray}{c}k=\{1,2,3\}\\ k\
eq i\end{subarray} }\left\{M(F^{i},I^{i})-E(F^{i},I^{k})\right\}\right\} \tag{8}\]  
\(M(F^{i},I^{i})\) denotes the matching and alignment of \(F^{i}\) with the corresponding segment \(I^{i}\), and is calculated as the length of the intersection \(\hat{F}^{i}_{i}\cap\hat{I}^{i}_{i}\) (green sub-segment in Figure 3(a)), minus the sum of the lengths of the non-intersecting parts of \(\hat{F}^{i}_{i}\) and \(\hat{I}^{i}_{i}\) (red sub-segments in Figure 3(a)).