pycvcam.optimize_rays_intersect#

optimize_rays_intersect(seq_rays)[source]#

Optimize the intersection point of multiple rays.

Lets consider \(N\) rays defined by their origins \(\mathbf{o}_i\) and directions \(\mathbf{d}_i\) for \(i = 1, 2, ..., N\). The goal is to find the point \(\mathbf{X}\) that minimizes the sum of squared distances to all rays, which can be formulated as:

\[\mathbf{X} = \arg\min_{\mathbf{X}} \sum_{i=1}^{N} \left\| (\mathbf{I} - \mathbf{d}_i \mathbf{d}_i^T) (\mathbf{X} - \mathbf{o}_i) \right\|^2\]

where \(\mathbf{I}\) is the identity matrix. This optimization problem can be solved using least squares, leading to a closed-form solution for the optimal intersection point.

Note

At least two rays are required for this optimization to be meaningful, but more rays can be used to improve the accuracy of the intersection point.

Parameters:

seq_rays (Sequence[Rays]) – A sequence of Rays objects, each representing n_points rays. The intersection point is optimized to minimize the distance to all rays.

Returns:

The optimized intersection point, shape (n_points, 3).

Return type:

numpy.ndarray