From 6027510c194529207e2f22017f1898e548647d86 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Wed, 23 Aug 2023 00:03:59 +0200 Subject: [PATCH] Fixing Windows build --- src/db/db/dbPoint.h | 196 +++++++++++++++++--------------------------- 1 file changed, 74 insertions(+), 122 deletions(-) diff --git a/src/db/db/dbPoint.h b/src/db/db/dbPoint.h index a3d44bfa6..ae8ff8638 100644 --- a/src/db/db/dbPoint.h +++ b/src/db/db/dbPoint.h @@ -270,12 +270,22 @@ public: * Scaling involves rounding which in our case is simply handled * with the coord_traits scheme. */ - point &operator*= (double s); + point &operator*= (double s) + { + m_x = coord_traits::rounded (m_x * s); + m_y = coord_traits::rounded (m_y * s); + return *this; + } /** * @brief Scaling self by some integer factor */ - point &operator*= (long s); + point &operator*= (long s) + { + m_x = coord_traits::rounded (m_x * s); + m_y = coord_traits::rounded (m_y * s); + return *this; + } /** * @brief Division by some divisor. @@ -284,62 +294,114 @@ public: * with the coord_traits scheme. */ - point &operator/= (double s); + point &operator/= (double s) + { + double mult = 1.0 / static_cast(s); + *this *= mult; + return *this; + } /** * @brief Dividing self by some integer divisor */ - point &operator/= (long s); + point &operator/= (long s) + { + double mult = 1.0 / static_cast(s); + *this *= mult; + return *this; + } /** * @brief The euclidian distance to another point * * @param d The other to compute the distance to. */ - distance_type distance (const point &p) const; + distance_type distance (const point &p) const + { + double ddx (p.x ()); + double ddy (p.y ()); + ddx -= double (x ()); + ddy -= double (y ()); + return coord_traits::rounded_distance (sqrt (ddx * ddx + ddy * ddy)); + } /** * @brief The euclidian distance of the point to (0,0) */ - distance_type distance () const; + distance_type distance () const + { + double ddx (x ()); + double ddy (y ()); + return coord_traits::rounded_distance (sqrt (ddx * ddx + ddy * ddy)); + } /** * @brief The euclidian distance to another point as double value * * @param d The other to compute the distance to. */ - double double_distance (const point &p) const; + double double_distance (const point &p) const + { + double ddx (p.x ()); + double ddy (p.y ()); + ddx -= double (x ()); + ddy -= double (y ()); + return sqrt (ddx * ddx + ddy * ddy); + } /** * @brief The euclidian distance of the point to (0,0) as double value */ - double double_distance () const; + double double_distance () const + { + double ddx (x ()); + double ddy (y ()); + return sqrt (ddx * ddx + ddy * ddy); + } /** * @brief The square euclidian distance to another point * * @param d The other to compute the distance to. */ - area_type sq_distance (const point &p) const; + area_type sq_distance (const point &p) const + { + return coord_traits::sq_length (p.x (), p.y (), x (), y ()); + } /** * @brief The square euclidian distance to point (0,0) * * @param d The other to compute the distance to. */ - area_type sq_distance () const; + area_type sq_distance () const + { + return coord_traits::sq_length (0, 0, x (), y ()); + } /** * @brief The square of the euclidian distance to another point as double value * * @param d The other to compute the distance to. */ - double sq_double_distance (const point &p) const; + double sq_double_distance (const point &p) const + { + double ddx (p.x ()); + double ddy (p.y ()); + ddx -= double (x ()); + ddy -= double (y ()); + return ddx * ddx + ddy * ddy; + } /** * @brief The square of the euclidian distance of the point to (0,0) as double value */ - double sq_double_distance () const; + double sq_double_distance () const + { + double ddx (x ()); + double ddy (y ()); + return ddx * ddx + ddy * ddy; + } /** * @brief String conversion @@ -454,116 +516,6 @@ operator/ (const db::point &p, Number s) return point (p.x () * mult, p.y () * mult); } -template -inline point & -point::operator/= (double s) -{ - double mult = 1.0 / static_cast(s); - *this *= mult; - return *this; -} - -template -inline point & -point::operator/= (long s) -{ - double mult = 1.0 / static_cast(s); - *this *= mult; - return *this; -} - -template -inline point & -point::operator*= (double s) -{ - m_x = coord_traits::rounded (m_x * s); - m_y = coord_traits::rounded (m_y * s); - return *this; -} - -template -inline point & -point::operator*= (long s) -{ - m_x = coord_traits::rounded (m_x * s); - m_y = coord_traits::rounded (m_y * s); - return *this; -} - -template -inline typename point::distance_type -point::distance (const point &p) const -{ - double ddx (p.x ()); - double ddy (p.y ()); - ddx -= double (x ()); - ddy -= double (y ()); - return coord_traits::rounded_distance (sqrt (ddx * ddx + ddy * ddy)); -} - -template -inline typename point::distance_type -point::distance () const -{ - double ddx (x ()); - double ddy (y ()); - return coord_traits::rounded_distance (sqrt (ddx * ddx + ddy * ddy)); -} - -template -inline double -point::double_distance (const point &p) const -{ - double ddx (p.x ()); - double ddy (p.y ()); - ddx -= double (x ()); - ddy -= double (y ()); - return sqrt (ddx * ddx + ddy * ddy); -} - -template -inline double -point::double_distance () const -{ - double ddx (x ()); - double ddy (y ()); - return sqrt (ddx * ddx + ddy * ddy); -} - -template -inline typename point::area_type -point::sq_distance (const point &p) const -{ - return coord_traits::sq_length (p.x (), p.y (), x (), y ()); -} - -template -inline typename point::area_type -point::sq_distance () const -{ - return coord_traits::sq_length (0, 0, x (), y ()); -} - -template -inline double -point::sq_double_distance (const point &p) const -{ - double ddx (p.x ()); - double ddy (p.y ()); - ddx -= double (x ()); - ddy -= double (y ()); - return ddx * ddx + ddy * ddy; -} - -template -inline double -point ::sq_double_distance () const -{ - double ddx (x ()); - double ddy (y ()); - return ddx * ddx + ddy * ddy; -} - /** * @brief The binary + operator (addition point and vector) *