@@ -74,7 +74,7 @@ inline bool orient(
7474 return (qy - py) * (rx - qx) - (qx - px) * (ry - qy) < 0.0 ;
7575}
7676
77- inline std::pair< double , double > circumcenter (
77+ inline Point circumcenter (
7878 const double ax,
7979 const double ay,
8080 const double bx,
@@ -93,7 +93,7 @@ inline std::pair<double, double> circumcenter(
9393 const double x = ax + (ey * bl - dy * cl) * 0.5 / d;
9494 const double y = ay + (dx * cl - ex * bl) * 0.5 / d;
9595
96- return std::make_pair (x, y);
96+ return Point (x, y);
9797}
9898
9999
@@ -102,16 +102,16 @@ struct compare {
102102 std::vector<double > const & coords;
103103 std::vector<double > dists;
104104
105- compare (std::vector<double > const & coords,
106- double center_x, double center_y) : coords(coords)
105+ compare (std::vector<double > const & coords, const Point& center) :
106+ coords (coords)
107107 {
108108 size_t n = coords.size () / 2 ;
109109 dists.reserve (n);
110110 double const *xcoord = coords.data ();
111111 double const *ycoord = coords.data () + 1 ;
112112 while (n--)
113113 {
114- dists.push_back (dist (*xcoord, *ycoord, center_x, center_y ));
114+ dists.push_back (dist (*xcoord, *ycoord, center. x (), center. y () ));
115115 xcoord += 2 ;
116116 ycoord += 2 ;
117117 }
@@ -192,8 +192,6 @@ Delaunator::Delaunator(std::vector<double> const& in_coords)
192192 hull_tri(),
193193 hull_start(),
194194 m_hash(),
195- m_center_x(),
196- m_center_y(),
197195 m_hash_size(),
198196 m_edge_stack() {
199197 std::size_t n = coords.size () >> 1 ;
@@ -279,10 +277,10 @@ Delaunator::Delaunator(std::vector<double> const& in_coords)
279277 std::swap (i1y, i2y);
280278 }
281279
282- std::tie (m_center_x, m_center_y) = circumcenter (i0x, i0y, i1x, i1y, i2x, i2y);
280+ m_center = circumcenter (i0x, i0y, i1x, i1y, i2x, i2y);
283281
284282 // sort the points by distance from the seed triangle circumcenter
285- std::sort (ids.begin (), ids.end (), compare{ coords, m_center_x, m_center_y });
283+ std::sort (ids.begin (), ids.end (), compare{ coords, m_center });
286284
287285 // initialize a hash table for storing edges of the advancing convex hull
288286 m_hash_size = static_cast <std::size_t >(std::llround (std::ceil (std::sqrt (n))));
@@ -516,8 +514,8 @@ std::size_t Delaunator::legalize(std::size_t a) {
516514}
517515
518516std::size_t Delaunator::hash_key (const double x, const double y) const {
519- const double dx = x - m_center_x ;
520- const double dy = y - m_center_y ;
517+ const double dx = x - m_center. x () ;
518+ const double dy = y - m_center. y () ;
521519 return fast_mod (
522520 static_cast <std::size_t >(std::llround (std::floor (pseudo_angle (dx, dy) * static_cast <double >(m_hash_size)))),
523521 m_hash_size);
0 commit comments