Skip to content

Commit

Permalink
comments fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeybelkov committed Dec 26, 2023
1 parent af824fa commit ebb5e1c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ from imops import interp1d # same as `scipy.interpolate.interp1d`
Works faster only for `ndim<=3, dtype=float32 or float64, order=1`

### Fast 2d linear interpolation
From https://github.com/alexeybelkov/parinterp/tree/rework
```python
import numpy as np
from imops.interp2d import Linear2DInterpolator
Expand Down
21 changes: 11 additions & 10 deletions imops/cpp/interp2d/delaunator/delaunator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ inline bool clockwise(const Point& p0, const Point& p1, const Point& p2)
Point v0 = Point::vector(p0, p1);
Point v1 = Point::vector(p0, p2);
double det = Point::determinant(v0, v1);
double dist = v0.magnitude2() + v1.magnitude2();
if (det == 0)
{
return false;
}
double dist = v0.magnitude2() + v1.magnitude2();
double reldet = std::abs(dist / det);
if (reldet > 1e14)
return false;
Expand Down Expand Up @@ -127,7 +127,9 @@ inline Point circumcenter(
//ABELL - This is suspect for div-by-0.
const double d = dx * ey - dy * ex;

assert(("Divide by zero exception", d == 0.0));
if (d == 0.0) {
throw std::runtime_error("Division by zero");
}

const double x = ax + (ey * bl - dy * cl) * 0.5 / d;
const double y = ay + (dx * cl - ex * bl) * 0.5 / d;
Expand Down Expand Up @@ -184,8 +186,8 @@ Delaunator::Delaunator(std::vector<double> const& in_coords)

double max_x = std::numeric_limits<double>::lowest();
double max_y = std::numeric_limits<double>::lowest();
double min_x = (std::numeric_limits<double>::max)();
double min_y = (std::numeric_limits<double>::max)();
double min_x = std::numeric_limits<double>::max();
double min_y = std::numeric_limits<double>::max();
for (const Point& p : m_points)
{
min_x = std::min(p.x(), min_x);
Expand All @@ -204,11 +206,10 @@ Delaunator::Delaunator(std::vector<double> const& in_coords)
std::size_t i2 = INVALID_INDEX;

// pick a seed point close to the centroid
double min_dist = (std::numeric_limits<double>::max)();
double min_dist = std::numeric_limits<double>::max();
for (size_t i = 0; i < m_points.size(); ++i)
{
const Point& p = m_points[i];
const double d = Point::dist2(center, p);
const double d = Point::dist2(center, m_points[i]);
if (d < min_dist) {
i0 = i;
min_dist = d;
Expand All @@ -217,7 +218,7 @@ Delaunator::Delaunator(std::vector<double> const& in_coords)

const Point& p0 = m_points[i0];

min_dist = (std::numeric_limits<double>::max)();
min_dist = std::numeric_limits<double>::max();

// find the point closest to the seed
for (std::size_t i = 0; i < n; i++) {
Expand All @@ -231,7 +232,7 @@ Delaunator::Delaunator(std::vector<double> const& in_coords)

const Point& p1 = m_points[i1];

double min_radius = (std::numeric_limits<double>::max)();
double min_radius = std::numeric_limits<double>::max();

// find the third point which forms the smallest circumcircle
// with the first two
Expand All @@ -245,7 +246,7 @@ Delaunator::Delaunator(std::vector<double> const& in_coords)
}
}

if (!(min_radius < (std::numeric_limits<double>::max)())) {
if (!(min_radius < std::numeric_limits<double>::max())) {
throw std::runtime_error("not triangulation");
}

Expand Down

0 comments on commit ebb5e1c

Please sign in to comment.