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{
59 Eigen::MatrixXf rr;
60 bool report;
61};
62
63//=============================================================================================================
75{
76public:
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()
114 {
115 return m_center;
116 }
117
118 //=========================================================================================================
124 float& radius()
125 {
126 return m_r;
127 }
128
129 //=========================================================================================================
140 static bool fit_sphere_to_points(const Eigen::MatrixXf& rr, float simplex_size, Eigen::VectorXf& r0, float& R);
141 static bool fit_sphere_to_points(float** rr, int np, float simplex_size, float* r0, float* R);
142
143private:
144 Eigen::Vector3f m_center;
145 float m_r;
146
147 //=========================================================================================================
155 static void calculate_cm_ave_dist(const Eigen::MatrixXf& rr, Eigen::VectorXf& cm, float& avep);
156
157 //=========================================================================================================
166 static Eigen::MatrixXf make_initial_simplex(const Eigen::VectorXf& pars, float size);
167
168 //=========================================================================================================
177 static float fit_eval(const Eigen::VectorXf& fitpar, const void* user_data);
178
179 //=========================================================================================================
191 static bool report_func(int loop, const Eigen::VectorXf& fitpar, double fval_lo, double fval_hi, double par_diff);
192
193 //=========================================================================================================
202 static float opt_rad(const Eigen::VectorXf& r0, const FitUser* user);
203};
204} // NAMESPACE
205
206#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:58
Eigen::MatrixXf rr
Definition sphere.h:59
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:113
float & radius()
Definition sphere.h:124
static Sphere fit_sphere(const Eigen::MatrixX3f &points)
Definition sphere.cpp:63
Sphere(const Eigen::Vector3f &center, float radius)
Definition sphere.cpp:55