From 3f4098a79fad6e4133aaa69599ccf68c6aac3946 Mon Sep 17 00:00:00 2001 From: VyasGuru <71374747+VyasGuru@users.noreply.github.com> Date: Wed, 28 Jan 2026 09:28:43 +0530 Subject: [PATCH] Optimised point --- include/cartesian_geom/point.h | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/include/cartesian_geom/point.h b/include/cartesian_geom/point.h index b8c8e32b4..53fe5e04a 100644 --- a/include/cartesian_geom/point.h +++ b/include/cartesian_geom/point.h @@ -112,14 +112,29 @@ class point return coeffs.sum(); } + template + void operator+= (const T& other) + { + if (other.rows() == 1 && other.cols() == d && d > 1) { + this->coeffs += other.transpose(); + } else { + this->coeffs += other; + } + } + void operator+= (const point& p) { coeffs += p.getCoefficients(); } - - void operator+= (const Coeff& coeffs) + + template + void operator-= (const T& other) { - this->coeffs += coeffs; + if (other.rows() == 1 && other.cols() == d && d > 1) { + this->coeffs -= other.transpose(); + } else { + this->coeffs -= other; + } } void operator-= (const point& p) @@ -127,10 +142,6 @@ class point coeffs -= p.getCoefficients(); } - void operator-= (const Coeff& coeffs) - { - this->coeffs -= coeffs; - } void operator= (const Coeff& coeffs) { @@ -205,8 +216,7 @@ class point } FT squared_length() const { - FT lsq = length(); - return lsq * lsq; + return coeffs.squaredNorm(); } FT length() const {