Closed-form (Jennings) and Nelder–Mead implementations of sphere fitting. More...
#include "sphere.h"#include "simplex_algorithm.h"#include <QDebug>#include <Eigen/Dense>#include <iostream>
Go to the source code of this file.
Closed-form (Jennings) and Nelder–Mead implementations of sphere fitting.
SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2026 MNE-CPP Authors
Implements the two static factories declared in sphere.h. The algebraic fit assembles the [2x 2y 2z 1] design matrix from the n input points and solves the resulting (n×4) linear system via Eigen::ColPivHouseholderQR; the sphere parameters fall out of the solution vector in O(n) time and require no initial guess.
The Nelder–Mead path builds a 4-vertex simplex in (cx, cy, cz, r) space, hands the geometric residual \(\sum_i (\|\mathbf{p}_i - \mathbf{c}\| - r)^2\) to UTILSLIB::SimplexAlgorithm::simplex_minimize and returns the refined sphere. It is more robust than the algebraic fit on noisy digitiser data because it minimises the geometric (not algebraic) residual, at the cost of a few hundred function evaluations.
Definition in file sphere.cpp.