v2.0.0
Loading...
Searching...
No Matches
sphere.h
Go to the documentation of this file.
1//=============================================================================================================
34
35#ifndef SPHERE_H
36#define SPHERE_H
37
38//=============================================================================================================
39// INCLUDES
40//=============================================================================================================
41
42#include "utils_global.h"
43
44//=============================================================================================================
45// EIGEN INCLUDES
46//=============================================================================================================
47
48#include <Eigen/Core>
49
50//=============================================================================================================
51// DEFINE NAMESPACE UTILSLIB
52//=============================================================================================================
53
54namespace UTILSLIB
55{
56
57//=============================================================================================================
58// TYPEDEFS
59//=============================================================================================================
60
62typedef struct {
63 Eigen::MatrixXf rr;
64 bool report;
65} *fitUserNew,fitUserRecNew;
66
67//=============================================================================================================
74{
75public:
76
77 //=========================================================================================================
84 Sphere(const Eigen::Vector3f& center, float radius);
85
86 //=========================================================================================================
94 static Sphere fit_sphere(const Eigen::MatrixX3f& points);
95
96 //=========================================================================================================
105 static Sphere fit_sphere_simplex(const Eigen::MatrixX3f& points, double simplex_size = 2e-2);
106
107 //=========================================================================================================
113 Eigen::Vector3f& center() { return m_center; }
114
115 //=========================================================================================================
121 float& radius() { return m_r; }
122
123 //=========================================================================================================
134 static bool fit_sphere_to_points(const Eigen::MatrixXf &rr, float simplex_size, Eigen::VectorXf &r0, float &R);
135 static bool fit_sphere_to_points(float **rr, int np, float simplex_size, float *r0, float *R);
136
137private:
138 Eigen::Vector3f m_center;
139 float m_r;
140
141 //=========================================================================================================
149 static void calculate_cm_ave_dist(const Eigen::MatrixXf &rr, Eigen::VectorXf &cm, float &avep);
150
151 //=========================================================================================================
160 static Eigen::MatrixXf make_initial_simplex(const Eigen::VectorXf &pars, float size);
161
162 //=========================================================================================================
171 static float fit_eval(const Eigen::VectorXf &fitpar, const void *user_data);
172
173 //=========================================================================================================
183 static bool report_func(int loop, const Eigen::VectorXf &fitpar, double fval);
184
185 //=========================================================================================================
194 static float opt_rad(const Eigen::VectorXf &r0, const fitUserNew user);
195};
196} // NAMESPACE
197
198#endif // SPHERE_H
utils library export/import macros.
#define UTILSSHARED_EXPORT
int fit_sphere_to_points(const MNESurfaceOrVolume::PointsT &rr, int np, float simplex_size, float *r0, float *R)
Shared utilities (I/O helpers, spectral analysis, layout management, warp algorithms).
Definition buildinfo.h:45
struct UTILSLIB::fitUserNew fitUserRecNew
Workspace for sphere-fitting optimisation, holding 3-D point coordinates and a report flag.
Definition sphere.h:62
Eigen::MatrixXf rr
Definition sphere.h:63
static bool fit_sphere_to_points(const Eigen::MatrixXf &rr, float simplex_size, Eigen::VectorXf &r0, float &R)
static Sphere fit_sphere_simplex(const Eigen::MatrixX3f &points, double simplex_size=2e-2)
Definition sphere.cpp:112
Eigen::Vector3f & center()
Definition sphere.h:113
float & radius()
Definition sphere.h:121
static Sphere fit_sphere(const Eigen::MatrixX3f &points)
Definition sphere.cpp:72
Sphere(const Eigen::Vector3f &center, float radius)
Definition sphere.cpp:64