Skip to content

Errors when special cases aren't handled. #13

@paltenburg

Description

@paltenburg

In line 128 of interpolate/points.py, in the function natural_neighbor_point(), geometry.circumcenter() is called:

c1 = geometry.circumcenter(grid_loc, tri.points[p1], tri.points[p2])

at this point, very often the ZeroDivisionError is raised from line 221 in geometry.circumcenter():

    d_div = (a_x * bc_y_diff + b_x * ca_y_diff + c_x * ab_y_diff)

    if d_div == 0:
        raise ZeroDivisionError 

This is due to special cases of how the following 3 points relate to each other:
grid_loc
tri.points[p1]
tri.points[p2]

There is the special case when there are duplice coordinates.
If the grid_loc has the exact coordinates of one of the two other points, it should probably just copy the value of the point with the same coordinates right? Now it goes through circumcenter() and crashes.

Also there is the special case where grid_loc, tri.points[p1], tri.points[p2] are on a straight vertical line (i.e. they share the same y coordinate).
In this case, the ZeroDivisionError is also raised because the *_y_diff variables are zero. I don't know what the solution should be in this case.

Ofcourse this happens in the geometry package, is it possible that there's a compatibillity issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions