46 if (samples.
size() < 6)
50 return Init(samples[0], samples[1], samples[2]);
56 if (samples.
size() < 1)
62 size_t c = samples.
size() / 2;
64 for (intptr_t i = 0; i <
c; ++i)
89 for (
size_t j = 0; j < 3; ++j)
94 for (
size_t j = 0; j < 3; ++j)
105 for (
int i = 0; i < 3; i++)
108 m_pos[i] = array[i + 4];
128template <
class WeightT>
147 template <
class IteratorT>
156 int size = end - begin;
157#pragma omp parallel for schedule(static) reduction(+ : chi)
158 for (
int idx = 0; idx < size; ++idx)
160 temp[idx] = params[0] * begin[idx][0] + params[1] * begin[idx][1] +
161 params[2] * begin[idx][2] - params[3];
162 chi += (values[idx] = WeightT::Weigh(temp[idx])) * values[idx];
167 template <
class IteratorT>
176 int size = end - begin;
177#pragma omp parallel for schedule(static)
178 for (
int idx = 0; idx < size; ++idx)
180 matrix[idx *
NumParams + 0] = begin[idx][0];
181 matrix[idx *
NumParams + 1] = begin[idx][1];
182 matrix[idx *
NumParams + 2] = begin[idx][2];
184 WeightT::template DerivWeigh<NumParams>(temp[idx], matrix + idx *
NumParams);
192 std::sqrt(params[0] * params[0] + params[1] * params[1] + params[2] * params[2]);
213 Vec3f normal(0, 0, 0);
214 Vec3f position(0, 0, 0);
215 for (
size_t i = 0; i < planes.
size(); ++i)
217 normal += weights[i] * planes[i].getNormal();
218 position += weights[i] * planes[i].getPosition();
221 *ip =
Plane(position, normal);
239 <<
"d " <<
m_dist << std::endl
241 for (
size_t i = 0; i < 3; ++i)
243 (*o) <<
m_pos[i] <<
" ";
250 for (
size_t i = 0; i < 3; ++i)
252 (*o) <<
m_pos[i] <<
" ";
261 return sizeof(
Vec3f) +
sizeof(
float) +
sizeof(
Vec3f);
273 for (
int i = 0; i < 3; i++)
276 array[i + 4] =
m_pos[i];
ScalarType Chi(const ScalarType *params, IteratorT begin, IteratorT end, ScalarType *values, ScalarType *temp) const
void Normalize(ScalarType *params) const
void Derivatives(const ScalarType *params, IteratorT begin, IteratorT end, const ScalarType *values, const ScalarType *temp, ScalarType *matrix) const
static bool Interpolate(const MiscLib::Vector< Plane > &planes, const MiscLib::Vector< float > &weights, Plane *ip)
static size_t SerializedFloatSize()
float getDistance(const Vec3f &pos) const
float Intersect(const Vec3f &p, const Vec3f &r) const
static size_t SerializedSize()
bool LeastSquaresFit(const PointCloud &pc, MiscLib::Vector< size_t >::const_iterator begin, MiscLib::Vector< size_t >::const_iterator end)
const Vec3f & getPosition() const
const Vec3f & getNormal() const
void Transform(float scale, const Vec3f &translate)
void Serialize(bool binary, std::ostream *o) const
bool InitAverage(const MiscLib::Vector< Vec3f > &samples)
float SignedDistance(const Vec3f &pos) const
bool Init(Vec3f p1, Vec3f p2, Vec3f p3)
float dot(const Vec3f &v) const
void Mean(PointsForwardIt begin, PointsForwardIt end, WeightsForwardIt weights, PointT *mean)
VectorXD< 3, float > Vector3Df
IndexedIterator< IndexIteratorT, IteratorT > IndexIterate(IndexIteratorT idxIt, IteratorT it)
bool MeanOfNormals(NormalsItT begin, NormalsItT end, WeightsItT weights, MeanT *mean)
Point cross(const Point &x, const Point &y)