void EllipseFit2<Real>::InitialGuess (int numPoints, const Vector2<Real>* points, Vector2<Real>& center, Matrix2<Real>& rotate, Real diag[2]) { Box2<Real> box = ContOrientedBox(numPoints, points); center = box.Center; rotate[0][0] = box.Axis[0].X(); rotate[0][1] = box.Axis[0].Y(); rotate[1][0] = box.Axis[1].X(); rotate[1][1] = box.Axis[1].Y(); diag[0] = box.Extent[0]; diag[1] = box.Extent[1]; }
void EllipseFit2<Real>::InitialGuess (int iQuantity, const Vector2<Real>* akPoint, Vector2<Real>& rkU, Matrix2<Real>& rkR, Real afD[2]) { Box2<Real> kBox = ContOrientedBox(iQuantity,akPoint); rkU = kBox.Center; rkR[0][0] = kBox.Axis[0].X(); rkR[0][1] = kBox.Axis[0].Y(); rkR[1][0] = kBox.Axis[1].X(); rkR[1][1] = kBox.Axis[1].Y(); afD[0] = kBox.Extent[0]; afD[1] = kBox.Extent[1]; }
bool c_CurveClustering::standardize(const c_Curve *_p_original_curve, c_Curve *&_p_standard_curve) { /*!< create an oriented bounding box for sample points */ const t_PointSet samples = _p_original_curve->get_samples(); Box2<t_Real> box = ContOrientedBox(samples.size(), samples.data()); /*!< ensure that extends of the box are not too small */ if (box.Extent[0] < epsilon) { box.Extent[0] = 1; } if (box.Extent[1] < epsilon) { box.Extent[1] = 1; } /*!< set the affine matrix in the transform, using the box */ Matrix3<t_Real> affine_matrix; c_Curve::t_Point const &first = samples.front(); __set_affine_matrix(box, Vector3<t_Real>(first.X(), first.Y(), 1), affine_matrix); m_affine_matrices.push_back(affine_matrix.Inverse()); /*!< calculate the new standard control points */ const t_PointSet old_controls = _p_original_curve->get_controls(); size_t n_controls = old_controls.size(); t_PointSet new_controls(n_controls); for (size_t i = 0; i < n_controls; ++i) { Vector3<t_Real> temp = affine_matrix * Vector3<t_Real>(old_controls[i].X(), old_controls[i].Y(), 1); new_controls[i] = Vector2<t_Real>(temp.X(), temp.Y()); } _p_standard_curve = new c_Curve(new_controls); return true; }