v2.0.0
Loading...
Searching...
No Matches
sphere.h
Go to the documentation of this file.
1//=============================================================================================================
29
30#ifndef SPHERE_H
31#define SPHERE_H
32
33//=============================================================================================================
34// INCLUDES
35//=============================================================================================================
36
37#include "math_global.h"
38
39//=============================================================================================================
40// EIGEN INCLUDES
41//=============================================================================================================
42
43#include <Eigen/Core>
44
45//=============================================================================================================
46// DEFINE NAMESPACE UTILSLIB
47//=============================================================================================================
48
49namespace UTILSLIB
50{
51
52//=============================================================================================================
53// TYPEDEFS
54//=============================================================================================================
55
57struct FitUser {
58 Eigen::MatrixXf rr;
59 bool report;
60};
61
62//=============================================================================================================
72{
73public:
74
75 //=========================================================================================================
82 Sphere(const Eigen::Vector3f& center, float radius);
83
84 //=========================================================================================================
92 static Sphere fit_sphere(const Eigen::MatrixX3f& points);
93
94 //=========================================================================================================
103 static Sphere fit_sphere_simplex(const Eigen::MatrixX3f& points, double simplex_size = 2e-2);
104
105 //=========================================================================================================
111 Eigen::Vector3f& center() { return m_center; }
112
113 //=========================================================================================================
119 float& radius() { return m_r; }
120
121 //=========================================================================================================
132 static bool fit_sphere_to_points(const Eigen::MatrixXf &rr, float simplex_size, Eigen::VectorXf &r0, float &R);
133 static bool fit_sphere_to_points(float **rr, int np, float simplex_size, float *r0, float *R);
134
135private:
136 Eigen::Vector3f m_center;
137 float m_r;
138
139 //=========================================================================================================
147 static void calculate_cm_ave_dist(const Eigen::MatrixXf &rr, Eigen::VectorXf &cm, float &avep);
148
149 //=========================================================================================================
158 static Eigen::MatrixXf make_initial_simplex(const Eigen::VectorXf &pars, float size);
159
160 //=========================================================================================================
169 static float fit_eval(const Eigen::VectorXf &fitpar, const void *user_data);
170
171 //=========================================================================================================
181 static bool report_func(int loop, const Eigen::VectorXf &fitpar, double fval_lo, double fval_hi, double par_diff);
182
183 //=========================================================================================================
192 static float opt_rad(const Eigen::VectorXf &r0, const FitUser* user);
193};
194} // NAMESPACE
195
196#endif // SPHERE_H
Eigen::Matrix3f R
Export/import macros and build-stamp accessors for MATHLIB.
#define MATHSHARED_EXPORT
Definition math_global.h:51
Shared utilities (I/O helpers, spectral analysis, layout management, warp algorithms).
Cost-function workspace for Sphere::fit_sphere_simplex: holds the nx3 point cloud and a verbose-repor...
Definition sphere.h:57
Eigen::MatrixXf rr
Definition sphere.h:58
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:103
Eigen::Vector3f & center()
Definition sphere.h:111
float & radius()
Definition sphere.h:119
static Sphere fit_sphere(const Eigen::MatrixX3f &points)
Definition sphere.cpp:63
Sphere(const Eigen::Vector3f &center, float radius)
Definition sphere.cpp:55