abellgithub / delaunator-cpp

A really fast C++ library for Delaunay triangulation of 2D points
MIT License
154 stars 33 forks source link

Logic error in bounding rectangle initialization. #6

Closed MK-3PP closed 4 years ago

MK-3PP commented 4 years ago

std::numeric_limits::min() is used to initialize maximum value variables that should grow to the highest encountered value. It represents the smallest positive normal double, so this value can never grow negative (e. g. for only negative inputs). Use std::numeric_limits::lowest() istead.

Lines 199 and 200 of delaunator.cpp: double max_x = (std::numeric_limits<double>::min)(); double max_y = (std::numeric_limits<double>::min)();

should be: double max_x = std::numeric_limits<double>::lowest(); double max_y = std::numeric_limits<double>::lowest();

abellgithub commented 4 years ago

Fixed with bf1ea6d82948a07759a4c1086e8b8b841f99b60e