Fix an overflow point causing wrong chained path
This commit is contained in:
parent
7bd2ce21ca
commit
0c2bfab5f2
1 changed files with 2 additions and 2 deletions
|
@ -36,12 +36,12 @@ int
|
||||||
Point::nearest_point_index(const Points points) const
|
Point::nearest_point_index(const Points points) const
|
||||||
{
|
{
|
||||||
int idx = -1;
|
int idx = -1;
|
||||||
long distance = -1;
|
double distance = -1; // double because long is limited to 2147483647 on some platforms and it's not enough
|
||||||
|
|
||||||
for (Points::const_iterator it = points.begin(); it != points.end(); ++it) {
|
for (Points::const_iterator it = points.begin(); it != points.end(); ++it) {
|
||||||
/* If the X distance of the candidate is > than the total distance of the
|
/* If the X distance of the candidate is > than the total distance of the
|
||||||
best previous candidate, we know we don't want it */
|
best previous candidate, we know we don't want it */
|
||||||
long d = pow(this->x - (*it).x, 2);
|
double d = pow(this->x - (*it).x, 2);
|
||||||
if (distance != -1 && d > distance) continue;
|
if (distance != -1 && d > distance) continue;
|
||||||
|
|
||||||
/* If the Y distance of the candidate is > than the total distance of the
|
/* If the Y distance of the candidate is > than the total distance of the
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue