50#include <visp3/core/vpException.h>
51#include <visp3/core/vpMath.h>
52#include <visp3/core/vpMatrix.h>
54#if defined(VISP_HAVE_FUNC__ISNAN)
58#if !(defined(VISP_HAVE_FUNC_ISNAN) || defined(VISP_HAVE_FUNC_STD_ISNAN)) || \
59 !(defined(VISP_HAVE_FUNC_ISINF) || defined(VISP_HAVE_FUNC_STD_ISINF))
60#if defined _MSC_VER || defined __BORLANDC__
62typedef unsigned __int64 uint64;
65typedef uint64_t uint64;
68#ifndef DOXYGEN_SHOULD_SKIP_THIS
69typedef union Cv64suf {
77const double vpMath::ang_min_sinc = 1.0e-8;
78const double vpMath::ang_min_mc = 2.5e-4;
87#if defined(VISP_HAVE_FUNC_ISNAN)
89#elif defined(VISP_HAVE_FUNC_STD_ISNAN)
90 return std::isnan(value);
91#elif defined(VISP_HAVE_FUNC__ISNAN)
92 return (_isnan(value) != 0);
97 return (((
unsigned)(ieee754.u >> 32) & 0x7fffffff) + ((
unsigned)ieee754.u != 0) > 0x7ff00000) != 0;
108#if defined(VISP_HAVE_FUNC_ISNAN)
110#elif defined(VISP_HAVE_FUNC_STD_ISNAN)
111 return std::isnan(value);
112#elif defined(VISP_HAVE_FUNC__ISNAN)
113 return (_isnan(value) != 0);
118 return ((
unsigned)ieee754.u & 0x7fffffff) > 0x7f800000;
131#if defined(VISP_HAVE_FUNC_ISINF)
133#elif defined(VISP_HAVE_FUNC_STD_ISINF)
134 return std::isinf(value);
135#elif defined(VISP_HAVE_FUNC__FINITE)
136 return !_finite(value);
141 return ((
unsigned)(ieee754.u >> 32) & 0x7fffffff) == 0x7ff00000 && (unsigned)ieee754.u == 0;
154#if defined(VISP_HAVE_FUNC_ISINF)
156#elif defined(VISP_HAVE_FUNC_STD_ISINF)
157 return std::isinf(value);
158#elif defined(VISP_HAVE_FUNC__FINITE)
159 return !_finite(value);
164 return ((
unsigned)ieee754.u & 0x7fffffff) == 0x7f800000;
179 if (fabs(x) < ang_min_mc)
182 return ((1.0 - cosx) / x / x);
196 if (fabs(x) < ang_min_mc)
199 return ((1.0 - sinx / x) / x / x);
212 if (fabs(x) < ang_min_sinc)
228 if (fabs(x) < ang_min_sinc)
247 size_t size = v.size();
249 double sum = std::accumulate(v.begin(), v.end(), 0.0);
251 return sum / (double)size;
267 std::vector<double> v_copy = v;
268 size_t size = v_copy.size();
271 std::nth_element(v_copy.begin(), v_copy.begin() + n, v_copy.end());
272 double val_n = v_copy[n];
277 std::nth_element(v_copy.begin(), v_copy.begin() + n - 1, v_copy.end());
278 return 0.5 * (val_n + v_copy[n - 1]);
299 std::vector<double> diff(v.size());
300#if VISP_CXX_STANDARD > VISP_CXX_STANDARD_98
301 std::transform(v.begin(), v.end(), diff.begin(), std::bind(std::minus<double>(), std::placeholders::_1, mean));
303 std::transform(v.begin(), v.end(), diff.begin(), std::bind2nd(std::minus<double>(), mean));
306 double sq_sum = std::inner_product(diff.begin(), diff.end(), diff.begin(), 0.0);
307 double divisor = (double)v.size();
308 if (useBesselCorrection && v.size() > 1) {
309 divisor = divisor - 1;
312 return std::sqrt(sq_sum / divisor);
330 if (imPts.size() < 3) {
334 double x_mean = 0, y_mean = 0;
335 for (
size_t i = 0; i < imPts.size(); i++) {
337 x_mean += imPt.
get_u();
338 y_mean += imPt.
get_v();
340 x_mean /= imPts.size();
341 y_mean /= imPts.size();
344 for (
size_t i = 0; i < imPts.size(); i++) {
346 AtA[0][0] += (imPt.
get_u() - x_mean)*(imPt.
get_u() - x_mean);
347 AtA[0][1] += (imPt.
get_u() - x_mean)*(imPt.
get_v() - y_mean);
348 AtA[1][1] += (imPt.
get_v() - y_mean)*(imPt.
get_v() - y_mean);
350 AtA[1][0] = AtA[0][1];
356 a = eigenvectors[0][0];
357 b = eigenvectors[1][0];
358 c = a*x_mean + b*y_mean;
361 for (
size_t i = 0; i < imPts.size(); i++) {
362 double x0 = imPts[i].get_u();
363 double y0 = imPts[i].get_v();
365 error += std::fabs(a*x0 + b*y0 - c);
368 return error / imPts.size();
Implementation of column vector and the associated operations.
error that can be emited by ViSP classes.
@ notInitialized
Used to indicate that a parameter is not initialized.
@ dimensionError
Bad dimension.
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
static double msinc(double sinx, double x)
static bool isNaN(double value)
static double getMedian(const std::vector< double > &v)
static double sinc(double x)
static double getStdev(const std::vector< double > &v, bool useBesselCorrection=false)
static int modulo(int a, int n)
static double lineFitting(const std::vector< vpImagePoint > &imPts, double &a, double &b, double &c)
static double getMean(const std::vector< double > &v)
static bool isInf(double value)
static double mcosc(double cosx, double x)
Implementation of a matrix and operations on matrices.
vpColVector eigenValues() const