Using CGAL::square()

This commit is contained in:
G Yuvan Shankar 2022-01-26 21:04:59 +05:30
parent 3a254451e2
commit e07672ab37
5 changed files with 20 additions and 20 deletions

View File

@ -100,9 +100,9 @@ linear_least_squares_fitting_2(InputIterator first,
FT y0 = t.center().y();
// and add to covariance matrix
covariance[0] += transformation[0][0] + area * x0*x0;
covariance[0] += transformation[0][0] + area * CGAL::square(x0);
covariance[1] += transformation[0][1] + area * x0*y0;
covariance[2] += transformation[1][1] + area * y0*y0;
covariance[2] += transformation[1][1] + area * CGAL::square(y0);
mass += area;
}
@ -111,9 +111,9 @@ linear_least_squares_fitting_2(InputIterator first,
// Translate the 2nd order moment calculated about the origin to
// the center of mass to get the covariance.
covariance[0] -= mass * (c.x() * c.x());
covariance[0] -= mass * (CGAL::square(c.x()));
covariance[1] -= mass * (c.x() * c.y());
covariance[2] -= mass * (c.y() * c.y());
covariance[2] -= mass * (CGAL::square(c.y()));
// solve for eigenvalues and eigenvectors.
// eigen values are sorted in ascending order,
@ -206,9 +206,9 @@ linear_least_squares_fitting_2(InputIterator first,
FT y0 = t.center().y();
// and add to covariance matrix
covariance[0] += transformation[0][0] + length * x0*x0;
covariance[0] += transformation[0][0] + length * CGAL::square(x0);
covariance[1] += transformation[0][1] + length * x0*y0;
covariance[2] += transformation[1][1] + length * y0*y0;
covariance[2] += transformation[1][1] + length * CGAL::square(y0);
mass += length;
}
@ -217,9 +217,9 @@ linear_least_squares_fitting_2(InputIterator first,
// Translate the 2nd order moment calculated about the origin to
// the center of mass to get the covariance.
covariance[0] -= mass * (c.x() * c.x());
covariance[0] -= mass * (CGAL::square(c.x()));
covariance[1] -= mass * (c.x() * c.y());
covariance[2] -= mass * (c.y() * c.y());
covariance[2] -= mass * (CGAL::square(c.y()));
// solve for eigenvalues and eigenvectors.
// eigen values are sorted in ascending order,

View File

@ -69,9 +69,9 @@ linear_least_squares_fitting_2(InputIterator first,
{
const Point& p = *it;
Vector d = p - c; // centered data point
covariance[0] += d.x() * d.x();
covariance[0] += CGAL::square(d.x());
covariance[1] += d.x() * d.y();
covariance[2] += d.y() * d.y();
covariance[2] += CGAL::square(d.y());
}
// solve for eigenvalues and eigenvectors.

View File

@ -104,9 +104,9 @@ linear_least_squares_fitting_2(InputIterator first,
FT xav0 = (x1-x0)/FT(2);
FT yav0 = (y2-y0)/FT(2);
// and add to covariance matrix
covariance[0] += transformation[0][0] + area * (x0*xav0*2 + x0*x0);
covariance[0] += transformation[0][0] + area * (x0*xav0*2 + CGAL::square(x0));
covariance[1] += transformation[0][1] + area * (x0*yav0 + xav0*y0 + x0*y0);
covariance[2] += transformation[1][1] + area * (y0*yav0*2 + y0*y0);
covariance[2] += transformation[1][1] + area * (y0*yav0*2 + CGAL::square(y0));
mass += area;
}
@ -115,9 +115,9 @@ linear_least_squares_fitting_2(InputIterator first,
// Translate the 2nd order moment calculated about the origin to
// the center of mass to get the covariance.
covariance[0] -= mass * (c.x() * c.x());
covariance[0] -= mass * (CGAL::square(c.x()));
covariance[1] -= mass * (c.x() * c.y());
covariance[2] -= mass * (c.y() * c.y());
covariance[2] -= mass * (CGAL::square(c.y()));
// solve for eigenvalues and eigenvectors.
// eigen values are sorted in ascending order,

View File

@ -104,9 +104,9 @@ linear_least_squares_fitting_2(InputIterator first,
// Translate the 2nd order moment calculated about the origin to
// the center of mass to get the covariance.
covariance[0] -= mass * (c.x() * c.x());
covariance[0] -= mass * CGAL::square(c.x()));
covariance[1] -= mass * (c.x() * c.y());
covariance[2] -= mass * (c.y() * c.y());
covariance[2] -= mass * (CGAL::square(c.y()));
// solve for eigenvalues and eigenvectors.
// eigen values are sorted in ascending order,

View File

@ -101,9 +101,9 @@ linear_least_squares_fitting_2(InputIterator first,
FT yav0 = (delta[2]+delta[3])/FT(3);
// and add to the covariance matrix
covariance[0] += transformation[0][0] + area * (x0*xav0*2 + x0*x0);
covariance[0] += transformation[0][0] + area * (x0*xav0*2 + CGAL::square(x0));
covariance[1] += transformation[0][1] + area * (x0*yav0 + xav0*y0 + x0*y0);
covariance[2] += transformation[1][1] + area * (y0*yav0*2 + y0*y0);
covariance[2] += transformation[1][1] + area * (y0*yav0*2 + CGAL::square(y0));
mass += area;
}
@ -112,9 +112,9 @@ linear_least_squares_fitting_2(InputIterator first,
// Translate the 2nd order moment calculated about the origin to
// the center of mass to get the covariance.
covariance[0] -= mass * (c.x() * c.x());
covariance[0] -= mass * (CGAL::square(c.x()));
covariance[1] -= mass * (c.x() * c.y());
covariance[2] -= mass * (c.y() * c.y());
covariance[2] -= mass * (CGAL::square(c.y()));
// std::cout<<"cov: "<<covariance[0]*covariance[2]<<" =? "<<covariance[1]*covariance[1]<<std::endl;