# Optimal View Estimation Algorithm and Evaluation with Deviation Angle Analysis
## 3 Methods
### Uniform Sampling on a Unit Sphere  
Similar to [16,32], a viewpoint for observing an object in three-dimensional (3D) space represents a viewpoint direction, which can be labeled as a point on the sphere surrounding the observed object. Therefore, generating random viewpoints on the sphere corresponds to the statistical problem of sampling on the sphere. The sphere is a curved space and the uniform sampling in this space is not an easy task. Traditionally, the implementation of uniform sampling on a sphere can be based on analytical formulas [33] or particle motion simulation. To improve the effect of sampling, we propose a new algorithm  
Figure 2: The flowchart of the proposed method. called the Fibonacci spherical uniform sampling algorithm based on repulsion and random optimization (FSUS-RR), combining the particle motion simulation with analytical formulas. The new sampling algorithm consists of two stages: generating sampling points through analytical methods, and moving sample points as particles. Through random experiments and verification, we chose the analytical method, the canonical Fibonacci lattice sampling method (CFLS) [33], to generate uniform sampling points on the unit sphere. Then, the initial sampling points are optimized by particle moving using two strategies: repulsion moving and random moving. Letting \(d_{i}^{ni}\) be the distance from viewpoint \(p_{i}\) to its closest neighbor, the moving step \(m_{step}\) is directly proportional to the difference \((d_{max}^{nei}-d_{min}^{ni})\), that is  
\[m_{step}=\tau\left(d_{max}^{nei}-d_{min}^{nei}\right)/2, \tag{1}\]  
where  
\[d_{max}^{nei}=\max_{j}\left\{d_{j}^{nei}\right\},\ d_{min}^{nei}=\min_{j}\left\{ d_{j}^{nei}\right\}. \tag{2}\]  
Letting \(v_{j}^{nei}\) be the unit vector from the closest neighbor of viewpoint \(p_{j}\) to \(p_{j}\), the moving direction \(v_{step}\) is staggered, that is, the direction of repulsive force \(v_{i}^{nei}\) and a random direction are alternately selected. The detail of our FSUS-RR is shown in Algorithm 1. This algorithm combines the sampling of analytical methods with a random movement strategy, achieving a balance between sampling efficiency and the uniform distribution effect; reasoning from this, the analytical method sampling has high efficiency in generating viewpoints, but the uniformity of sampling points is insufficient. The random movement method can improve the uniform distribution effect, but the sampling efficiency is low. ```
0:\(N\), // The number of sampling points, \(I_{nie}\) // The number of iterations Output: \(\mathrm{V}=\left\{\mathrm{p}_{i}(x_{i},y_{i},z_{i})\right\}\) // the coordinates of N points on the unit sphere
1:\(\mathrm{\eta}=\left(1+\sqrt{5}\right)/2\) // for steps 1 through 6, use the CFLS method [33]
2:for \(i\) from 0 to \(N-1\)
3:\(\mathrm{\vartheta}=2\pi\mathrm{i}/\mathrm{\eta}\)
4:\(\mathrm{\varphi}=\cos^{-1}(1-2(i+0.5)/N)\)
5:\(\mathrm{p}_{i}=(x_{i},y_{i},z_{i})=(\cos\mathrm{\theta}\mathrm{sin}\,\mathrm{ \varphi},\ \mathrm{sin}\,\mathrm{\theta}\mathrm{sin}\,\mathrm{\varphi},\ \mathrm{cos}\,\mathrm{\varphi})\)
6:end
7:flag = 1;
8:for \(i\) from 1 to \(I_{lie}\)
9: Build \(kd\) -- tree using all sampling points \(\left\{\mathrm{p}_{i}(x_{i},y_{i},z_{i})\right\}\)
10: Calculating \(m_{step}\) using Equation (1)
11: for j from 1 to \(N\)
12: if flag == 1, then
13:\(v_{step}=v_{j}^{prii}\)
14: else
15:\(v_{step}\) is a random unit vector
16: end
17:\(\mathrm{p}_{j}=\mathrm{p}_{j}+m_{step}\times v_{step}\) // Update the position of \(\mathrm{p}_{j}\)
18: flag = 1-flag
19:\(\mathrm{p}_{j}=\mathrm{p}_{j}/\left\|\mathrm{p}_{j}\right\|\) // In terms of vector units
20: end
21:end
22:Output the sampling points \(\mathrm{V}=\left\{\mathrm{p}_{i}(x_{i},y_{i},z_{i})\right\}\)
```  
**Algorithm 1**FSUS-RRTo verify the effectiveness of our method, we conducted comparative experiments.