2010-05-31 07:40:08 +00:00
|
|
|
// This code is in the public domain -- Ignacio Castaño <castano@gmail.com>
|
2008-11-22 08:30:20 +00:00
|
|
|
|
2010-05-27 23:19:24 +00:00
|
|
|
#pragma once
|
2008-11-22 08:30:20 +00:00
|
|
|
#ifndef NV_MATH_FITTING_H
|
|
|
|
#define NV_MATH_FITTING_H
|
|
|
|
|
2012-04-30 23:02:46 +00:00
|
|
|
#include "Vector.h"
|
|
|
|
#include "Plane.h"
|
2008-11-22 08:30:20 +00:00
|
|
|
|
|
|
|
namespace nv
|
|
|
|
{
|
2011-10-10 19:35:21 +00:00
|
|
|
class Vector3;
|
|
|
|
class Plane;
|
|
|
|
|
2010-05-27 23:19:24 +00:00
|
|
|
namespace Fit
|
|
|
|
{
|
|
|
|
Vector3 computeCentroid(int n, const Vector3 * points);
|
2011-10-10 19:35:21 +00:00
|
|
|
Vector3 computeCentroid(int n, const Vector3 * points, const float * weights, const Vector3 & metric);
|
2008-11-22 08:30:20 +00:00
|
|
|
|
2010-05-27 23:19:24 +00:00
|
|
|
Vector3 computeCovariance(int n, const Vector3 * points, float * covariance);
|
2011-10-10 19:35:21 +00:00
|
|
|
Vector3 computeCovariance(int n, const Vector3 * points, const float * weights, const Vector3 & metric, float * covariance);
|
2008-11-22 08:30:20 +00:00
|
|
|
|
2010-05-27 23:19:24 +00:00
|
|
|
Vector3 computePrincipalComponent(int n, const Vector3 * points);
|
2011-10-10 19:35:21 +00:00
|
|
|
Vector3 computePrincipalComponent(int n, const Vector3 * points, const float * weights, const Vector3 & metric);
|
2009-03-01 00:18:47 +00:00
|
|
|
|
2010-05-27 23:19:24 +00:00
|
|
|
Plane bestPlane(int n, const Vector3 * points);
|
2012-02-14 16:31:25 +00:00
|
|
|
bool isPlanar(int n, const Vector3 * points, float epsilon = NV_EPSILON);
|
|
|
|
|
|
|
|
bool eigenSolveSymmetric (float matrix[6], float eigenValues[3], Vector3 eigenVectors[3]);
|
|
|
|
|
2009-03-01 00:18:47 +00:00
|
|
|
|
2010-05-27 23:19:24 +00:00
|
|
|
// Returns number of clusters [1-4].
|
2011-10-10 19:35:21 +00:00
|
|
|
int compute4Means(int n, const Vector3 * points, const float * weights, const Vector3 & metric, Vector3 * cluster);
|
2010-05-27 23:19:24 +00:00
|
|
|
}
|
2008-11-22 08:30:20 +00:00
|
|
|
|
|
|
|
} // nv namespace
|
|
|
|
|
|
|
|
#endif // NV_MATH_FITTING_H
|