v2.0.0
Loading...
Searching...
No Matches
sphere.cpp File Reference

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>
Include dependency graph for sphere.cpp:

Go to the source code of this file.

Detailed Description

Closed-form (Jennings) and Nelder–Mead implementations of sphere fitting.

SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2026 MNE-CPP Authors

Author
Christoph Dinh chris.nosp@m.toph.nosp@m..dinh.nosp@m.@mne.nosp@m.-cpp..nosp@m.org
Since
2.0.0
Date
March 2026

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.