From a2dd287a07d92b91863af24524bac9fc2c1a7f4c Mon Sep 17 00:00:00 2001 From: G Yuvan Shankar Date: Mon, 24 Jan 2022 19:28:36 +0530 Subject: [PATCH] Simplified expressions --- .../CGAL/linear_least_squares_fitting_circles_2.h | 14 +++++++------- .../linear_least_squares_fitting_rectangles_2.h | 8 ++++---- .../CGAL/linear_least_squares_fitting_segments_2.h | 8 ++++---- .../linear_least_squares_fitting_triangles_2.h | 8 ++++---- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_circles_2.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_circles_2.h index d6abf3d1482..f856fafccc4 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_circles_2.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_circles_2.h @@ -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[1] += -mass * (c.x() * c.y()); - covariance[2] += -mass * (c.y() * c.y()); + covariance[0] -= mass * (c.x() * c.x()); + covariance[1] -= mass * (c.x() * c.y()); + covariance[2] -= mass * (c.y() * c.y()); // solve for eigenvalues and eigenvectors. // eigen values are sorted in ascending order, @@ -194,7 +194,7 @@ linear_least_squares_fitting_2(InputIterator first, 0.0, radius}; Matrix transformation = init_matrix(2,delta); FT length = 2 * radius; - CGAL_assertion(length != 0.0); + CGAL_assertion(length != FT(0)); // Find the 2nd order moment for the circle wrt to the origin by an affine transformation. @@ -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[1] += -mass * (c.x() * c.y()); - covariance[2] += -mass * (c.y() * c.y()); + covariance[0] -= mass * (c.x() * c.x()); + covariance[1] -= mass * (c.x() * c.y()); + covariance[2] -= mass * (c.y() * c.y()); // solve for eigenvalues and eigenvectors. // eigen values are sorted in ascending order, diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_rectangles_2.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_rectangles_2.h index 3bec5e8d4d5..48e441e9ca5 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_rectangles_2.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_rectangles_2.h @@ -93,7 +93,7 @@ linear_least_squares_fitting_2(InputIterator first, Matrix transformation = init_matrix(2,delta); FT area = (x1-x0)*(y2-y0); - CGAL_assertion(area != 0.0); + CGAL_assertion(area != FT(0)); // Find the 2nd order moment for the rectangle wrt to the origin by an affine transformation. @@ -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[1] += -mass * (c.x() * c.y()); - covariance[2] += -mass * (c.y() * c.y()); + covariance[0] -= mass * (c.x() * c.x()); + covariance[1] -= mass * (c.x() * c.y()); + covariance[2] -= mass * (c.y() * c.y()); // solve for eigenvalues and eigenvectors. // eigen values are sorted in ascending order, diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_segments_2.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_segments_2.h index a6d581d97df..b35d3742583 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_segments_2.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_segments_2.h @@ -85,7 +85,7 @@ linear_least_squares_fitting_2(InputIterator first, Matrix transformation = init_matrix(2,delta); using std::sqrt; FT length = CGAL::approximate_sqrt(t.squared_length()); - CGAL_assertion(length != 0.0); + CGAL_assertion(length != FT(0)); // Find the 2nd order moment for the segment wrt to the origin by an affine transformation. @@ -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[1] += -mass * (c.x() * c.y()); - covariance[2] += -mass * (c.y() * c.y()); + covariance[0] -= mass * (c.x() * c.x()); + covariance[1] -= mass * (c.x() * c.y()); + covariance[2] -= mass * (c.y() * c.y()); // solve for eigenvalues and eigenvectors. // eigen values are sorted in ascending order, diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_triangles_2.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_triangles_2.h index ab96ad6d408..8f78ea09ea0 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_triangles_2.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_triangles_2.h @@ -89,7 +89,7 @@ linear_least_squares_fitting_2(InputIterator first, Matrix transformation = init_matrix(2,delta); FT area = FT(0.5) * CGAL::abs(LA::determinant(transformation)); - CGAL_assertion(area!=0); + CGAL_assertion(area!=FT(0)); // Find the 2nd order moment for the triangle wrt to the origin by an affine transformation. @@ -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[1] += -mass * (c.x() * c.y()); - covariance[2] += -mass * (c.y() * c.y()); + covariance[0] -= mass * (c.x() * c.x()); + covariance[1] -= mass * (c.x() * c.y()); + covariance[2] -= mass * (c.y() * c.y()); // std::cout<<"cov: "<