Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integer division error with Float32 for clipped Voronoi #72

Closed
DanielVandH opened this issue Aug 6, 2023 · 9 comments · Fixed by #74 or #165
Closed

Integer division error with Float32 for clipped Voronoi #72

DanielVandH opened this issue Aug 6, 2023 · 9 comments · Fixed by #74 or #165

Comments

@DanielVandH
Copy link
Member

Found while looking into MakieOrg/Makie.jl#3102.

points = [
    Float32[0.32965052, 0.7966664],
    Float32[0.015137732, 0.31555605],
    Float32[0.54775107, 0.7222514],
    Float32[0.687552, 0.6982844],
    Float32[0.65762305, 0.5177773],
    Float32[0.9649102, 0.8300816],
    Float32[0.12174326, 0.82220316],
    Float32[0.007668495, 0.7747718],
    Float32[0.3144052, 0.5493178],
    Float32[0.6848137, 0.12493092],
    Float32[0.39197737, 0.6912688],
    Float32[0.41400427, 0.025964081],
    Float32[0.35919905, 0.7255166],
    Float32[0.80712754, 0.3415957],
    Float32[0.542679, 0.51094216],
    Float32[0.092720866, 0.90151125],
    Float32[0.90992355, 0.8814645],
    Float32[0.02194357, 0.00064593554],
    Float32[0.9616154, 0.10633117],
    Float32[0.0044495463, 0.97074896],
    Float32[0.4309939, 0.5323847],
    Float32[0.90867966, 0.55974066],
    Float32[0.580766, 0.7668439],
    Float32[0.8563475, 0.88143903],
    Float32[0.18311942, 0.8367877]
]
voronoi(triangulate(points), true)

┌ Warning: Invalid input, empty interval is returned
└ @ IntervalArithmetic C:\Users\User\.julia\packages\IntervalArithmetic\EquAX\src\intervals\intervals.jl:106
┌ Warning: Invalid input, empty interval is returned
└ @ IntervalArithmetic C:\Users\User\.julia\packages\IntervalArithmetic\EquAX\src\intervals\intervals.jl:106
ERROR: DivideError: integer division error
Stacktrace:
  [1] sub!(z::Rational{BigInt}, x::Rational{BigInt}, y::Rational{BigInt})
    @ Base.GMP.MPQ .\gmp.jl:1012
  [2] -
    @ ExactPredicates .\gmp.jl:1061 [inlined]
  [3] orient_reference(u::Tuple{Float64, Float64}, v::Tuple{Float64, Float64}, w::Tuple{Float64, Float64})
    @ ExactPredicates C:\Users\User\.julia\packages\ExactPredicates\GSx4w\src\Codegen.jl:171
  [4] orient_slow(u::Tuple{Float64, Float64}, v::Tuple{Float64, Float64}, w::Tuple{Float64, Float64})
    @ ExactPredicates C:\Users\User\.julia\packages\ExactPredicates\GSx4w\src\Codegen.jl:449
  [5] orient
    @ DelaunayTriangulation C:\Users\User\.julia\packages\ExactPredicates\GSx4w\src\Codegen.jl:459 [inlined]
  [6] orient_predicate(p::Tuple{Float32, Float32}, q::Tuple{Float32, Float32}, r::Tuple{Float32, Float32})
    @ DelaunayTriangulation c:\Users\User\.julia\dev\DelaunayTriangulation\src\predicates\general.jl:18
  [7] point_position_relative_to_line
    @ DelaunayTriangulation c:\Users\User\.julia\dev\DelaunayTriangulation\src\predicates\general.jl:159 [inlined]
  [8] intersection_of_edge_and_bisector_ray(a::Tuple{Float32, Float32}, b::Tuple{Float32, Float32}, c::Tuple{Float32, Float32})
    @ DelaunayTriangulation c:\Users\User\.julia\dev\DelaunayTriangulation\src\geometry_utils\intersections.jl:158
  [9] process_ray_intersection!(vorn::VoronoiTessellation{…}, u::Int64, v::Int64, incident_polygon::Int64, intersected_edge_cache::Vector{…}, segment_intersections::Vector{…}, boundary_sites::Dict{…}, exterior_circumcenters::Set{…}, equal_circumcenter_mapping::Dict{…})
    @ DelaunayTriangulation c:\Users\User\.julia\dev\DelaunayTriangulation\src\voronoi\clipped_construction.jl:77
 [10] process_polygon!(vorn::VoronoiTessellation{…}, e::Tuple{…}, incident_polygon::Int64, boundary_sites::Dict{…}, segment_intersections::Vector{…}, intersected_edge_cache::Vector{…}, exterior_circumcenters::Set{…}, equal_circumcenter_mapping::Dict{…})
    @ DelaunayTriangulation c:\Users\User\.julia\dev\DelaunayTriangulation\src\voronoi\clipped_construction.jl:313
 [11] dequeue_and_process!(vorn::VoronoiTessellation{…}, polygon_edge_queue::Queue{…}, edges_to_process::Set{…}, intersected_edge_cache::Vector{…}, left_edge_intersectors::Set{…}, right_edge_intersectors::Set{…}, current_edge_intersectors::Set{…}, processed_pairs::Set{…}, boundary_sites::Dict{…}, segment_intersections::Vector{…}, exterior_circumcenters::Set{…}, equal_circumcenter_mapping::Dict{…})
    @ DelaunayTriangulation c:\Users\User\.julia\dev\DelaunayTriangulation\src\voronoi\clipped_construction.jl:437
 [12] find_all_intersections(vorn::VoronoiTessellation{Triangulation{…}, Tuple{…}, Int64, Tuple{…}, Set{…}, Tuple{…}})
    @ DelaunayTriangulation c:\Users\User\.julia\dev\DelaunayTriangulation\src\voronoi\clipped_construction.jl:476
 [13] clip_voronoi_tessellation!(vorn::VoronoiTessellation{Triangulation{…}, Tuple{…}, Int64, Tuple{…}, Set{…}, Tuple{…}}, is_convex::Bool)
    @ DelaunayTriangulation c:\Users\User\.julia\dev\DelaunayTriangulation\src\voronoi\main.jl:42
 [14] voronoi(tri::Triangulation{Vector{…}, Set{…}, Int64, Tuple{…}, Set{…}, Vector{…}, Dict{…}, OrderedDict{…}, OrderedDict{…}, Dict{…}}, clip::Bool)
    @ DelaunayTriangulation c:\Users\User\.julia\dev\DelaunayTriangulation\src\voronoi\main.jl:30
 [15] top-level scope
    @ Untitled-1:28
Some type information was truncated. Use `show(err)` to see complete types.
@DanielVandH
Copy link
Member Author

Due to infinities somehow:

(p, q, r) = ((0.015137732f0, 0.31555605f0), (0.0044495463f0, 0.97074896f0), (-Inf32, -Inf32))
┌ Warning: Invalid input, empty interval is returned
└ @ IntervalArithmetic C:\Users\User\.julia\packages\IntervalArithmetic\EquAX\src\intervals\intervals.jl:106
┌ Warning: Invalid input, empty interval is returned
└ @ IntervalArithmetic C:\Users\User\.julia\packages\IntervalArithmetic\EquAX\src\intervals\intervals.jl:106

@DanielVandH
Copy link
Member Author

This is the issue

julia> p
(0.007668495f0, 0.7747718f0)

julia> q
(0.0044495463f0, 0.97074896f0)

julia> r
(0.015137732f0, 0.31555605f0)

julia> DelaunayTriangulation.triangle_area(p, q, r)        
0.0f0

julia> DelaunayTriangulation.triangle_area(Float64.(p), Float64.(q), Float64.(r))
7.196139036472352e-6

@DanielVandH
Copy link
Member Author

This formula

squared_triangle_area(ℓ₁²::Number, ℓ₂²::Number, ℓ₃²::Number) = (4ℓ₁² * ℓ₂² - (ℓ₁² + ℓ₂² - ℓ₃²)^2) / 16 # Heron's formula

is not always the best. If I use this formula

squared_triangle_area(ℓ₁²::Number, ℓ₂²::Number, ℓ₃²::Number) = let a = sqrt(ℓ₃²), b = sqrt(ℓ₂²), c = sqrt(ℓ₁²)
    return (a + (b + c)) * (c - (a - b)) * (c + (a - b)) * (a + (b - c)) / 16 # https://people.eecs.berkeley.edu/~wkahan/Triangle.pdf
end

then

julia> DelaunayTriangulation.triangle_area(p, q, r)
2.0964168f-5

@CNOT
Copy link

CNOT commented Feb 23, 2024

I'm still getting this error while trying to build a clipped voronoi plot (I can provide the code if you think its helpful). If you believe the issue is because of a division by zero error, I think a better formula to use would be the shoelace formula, which is basically a determinant of the coordinates of the triangle which doesn't require a division.

@DanielVandH
Copy link
Member Author

The shoelace formula would perform worse in most cases; the division is not impactful here. Can you provide an MWE for your case, please?

@CNOT
Copy link

CNOT commented Feb 24, 2024

Unfortunately my code is far from minimum length, but I was able to reproduce the issue on a simpler geometry:

using GeometryBasics, DelaunayTriangulation, CairoMakie
function is_point_in_polygon(point::Point, polygon::Polygon)
    # Check if the point is on the boundary of the polygon
    point in polygon && return false

    n = length(coordinates(polygon))
    inside = false

    p1 = polygon[1]
    for i in 2:n+1
        p2 = polygon[mod1(i, n)]
        if ((p1[2] > point[2]) != (p2[2] > point[2])) && (point[1] < (p2[1] - p1[1]) * (point[2] - p1[2]) / (p2[2] - p1[2]) + p1[1])
            inside = !inside
        end
        p1 = copy(p2)
    end

    return inside
end

b_vec = reverse([Point(0.0, 0.0), Point(0.0, 1.0), Point(1.0, 1.0), Point(1.0, 0.0), Point(0.5, 0.5)])
p = Polygon(b_vec)
p2 = coordinates(p)
push!(p2,p2[1])
boundary_nodes, points2 = convert_boundary_points_to_indices(getxy.(p2))
triangulation = triangulate(points2; boundary_nodes)
minx, miny = extrema(p2)[1]
maxx, maxy = extrema(p2)[2]

for i in range(minx + 0.05, maxx - 0.05, step=0.05)
    for j in range(maxy - 0.05, miny + 0.05, step=-0.05)
        if is_point_in_polygon(Point(i, j), p)
            try
                add_point!(triangulation, (i, j))
            catch
                @warn "There was a problem adding this point."
            end
        end
    end
end

vorn = voronoi(triangulation, false)
voronoiplot(vorn,show_generators = true)

Here you can see two issues, one is that sometimes add_point! doesn't work and throws an error. The other is caused by voronoiplot and the error message I get is:

┌ Warning: invalid interval, NaI is returned
└ @ IntervalArithmetic /home/ali/.julia/packages/IntervalArithmetic/7FL3g/src/intervals/construction.jl:417
┌ Warning: interval part of NaI
└ @ IntervalArithmetic /home/ali/.julia/packages/IntervalArithmetic/7FL3g/src/intervals/construction.jl:299
┌ Warning: invalid interval, NaI is returned
└ @ IntervalArithmetic /home/ali/.julia/packages/IntervalArithmetic/7FL3g/src/intervals/construction.jl:417
┌ Warning: interval part of NaI
└ @ IntervalArithmetic /home/ali/.julia/packages/IntervalArithmetic/7FL3g/src/intervals/construction.jl:299
┌ Warning: interval part of NaI
└ @ IntervalArithmetic /home/ali/.julia/packages/IntervalArithmetic/7FL3g/src/intervals/construction.jl:299
┌ Warning: interval part of NaI
└ @ IntervalArithmetic /home/ali/.julia/packages/IntervalArithmetic/7FL3g/src/intervals/construction.jl:299
┌ Warning: interval part of NaI
└ @ IntervalArithmetic /home/ali/.julia/packages/IntervalArithmetic/7FL3g/src/intervals/construction.jl:299
┌ Warning: interval part of NaI
└ @ IntervalArithmetic /home/ali/.julia/packages/IntervalArithmetic/7FL3g/src/intervals/construction.jl:299
┌ Warning: interval part of NaI
└ @ IntervalArithmetic /home/ali/.julia/packages/IntervalArithmetic/7FL3g/src/intervals/construction.jl:299
┌ Warning: interval part of NaI
└ @ IntervalArithmetic /home/ali/.julia/packages/IntervalArithmetic/7FL3g/src/intervals/construction.jl:299
┌ Warning: interval part of NaI
└ @ IntervalArithmetic /home/ali/.julia/packages/IntervalArithmetic/7FL3g/src/intervals/construction.jl:299
┌ Warning: interval part of NaI
└ @ IntervalArithmetic /home/ali/.julia/packages/IntervalArithmetic/7FL3g/src/intervals/construction.jl:299
{
	"name": "DivideError",
	"message": "DivideError: integer division error",
	"stack": "DivideError: integer division error

Stacktrace:
  [1] sub!(z::Rational{BigInt}, x::Rational{BigInt}, y::Rational{BigInt})
    @ Base.GMP.MPQ ./gmp.jl:1012
  [2] -
    @ ./gmp.jl:1061 [inlined]
  [3] orient_reference(u::Tuple{Float64, Float64}, v::Tuple{Float64, Float64}, w::Tuple{Float64, Float64})
    @ ExactPredicates ~/.julia/packages/ExactPredicates/fhcrS/src/Codegen.jl:182
  [4] orient_slow(u::Tuple{Float64, Float64}, v::Tuple{Float64, Float64}, w::Tuple{Float64, Float64})
    @ ExactPredicates ~/.julia/packages/ExactPredicates/fhcrS/src/Codegen.jl:460
  [5] orient
    @ ~/.julia/packages/ExactPredicates/fhcrS/src/Codegen.jl:470 [inlined]
  [6] orient_predicate(p::Tuple{Float64, Float64}, q::Tuple{Float64, Float64}, r::Tuple{Float64, Float64})
    @ DelaunayTriangulation ~/.julia/packages/DelaunayTriangulation/Da51i/src/predicates/general.jl:18
  [7] point_position_relative_to_line
    @ ~/.julia/packages/DelaunayTriangulation/Da51i/src/predicates/general.jl:159 [inlined]
  [8] call_composed
    @ ./operators.jl:1045 [inlined]
  [9] call_composed
    @ ./operators.jl:1044 [inlined]
 [10] ComposedFunction
    @ ./operators.jl:1041 [inlined]
 [11] clip_polygon_to_edge(input_list::DelaunayTriangulation.Polygon{Tuple{Float64, Float64}, SubArray{Int64, 1, Vector{Int64}, Tuple{UnitRange{Int64}}, true}, Vector{Tuple{Float64, Float64}}}, q::Tuple{Float64, Float64}, p::Tuple{Float64, Float64})
    @ DelaunayTriangulation ~/.julia/packages/DelaunayTriangulation/Da51i/src/geometry_utils/sutherland_hodgman.jl:53
 [12] clip_polygon(poly::DelaunayTriangulation.Polygon{Tuple{Float64, Float64}, SubArray{Int64, 1, Vector{Int64}, Tuple{UnitRange{Int64}}, true}, Vector{Tuple{Float64, Float64}}}, clip_poly::DelaunayTriangulation.Polygon{Tuple{Float64, Float64}, NTuple{4, Int64}, NTuple{4, Tuple{Float64, Float64}}})
    @ DelaunayTriangulation ~/.julia/packages/DelaunayTriangulation/Da51i/src/geometry_utils/sutherland_hodgman.jl:85
 [13] clip_bounded_polygon_to_bounding_box(vorn::VoronoiTessellation{Triangulation{Vector{Tuple{Float64, Float64}}, Set{Tuple{Int64, Int64, Int64}}, Int64, Tuple{Int64, Int64}, Set{Tuple{Int64, Int64}}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Tuple{Vector{Int64}, Int64}}, OrderedCollections.OrderedDict{Int64, Vector{Int64}}, OrderedCollections.OrderedDict{Int64, UnitRange{Int64}}, Dict{Int64, DelaunayTriangulation.RepresentativeCoordinates{Int64, Float64}}}, Tuple{Float64, Float64}, Int64, Tuple{Int64, Int64, Int64}, Set{Int64}, Tuple{Int64, Int64}}, i::Int64, bounding_box::NTuple{4, Float64})
    @ DelaunayTriangulation ~/.julia/packages/DelaunayTriangulation/Da51i/src/voronoi/coordinates.jl:69
 [14] get_bounded_polygon_coordinates
    @ ~/.julia/packages/DelaunayTriangulation/Da51i/src/voronoi/coordinates.jl:235 [inlined]
 [15] get_polygon_coordinates(vorn::VoronoiTessellation{Triangulation{Vector{Tuple{Float64, Float64}}, Set{Tuple{Int64, Int64, Int64}}, Int64, Tuple{Int64, Int64}, Set{Tuple{Int64, Int64}}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Tuple{Vector{Int64}, Int64}}, OrderedCollections.OrderedDict{Int64, Vector{Int64}}, OrderedCollections.OrderedDict{Int64, UnitRange{Int64}}, Dict{Int64, DelaunayTriangulation.RepresentativeCoordinates{Int64, Float64}}}, Tuple{Float64, Float64}, Int64, Tuple{Int64, Int64, Int64}, Set{Int64}, Tuple{Int64, Int64}}, i::Int64, bounding_box::NTuple{4, Float64})
    @ DelaunayTriangulation ~/.julia/packages/DelaunayTriangulation/Da51i/src/voronoi/coordinates.jl:27
 [16] get_voronoi_tiles!(generators::Vector{Point{2, Float32}}, polygons::Vector{Polygon{2, Float32, Point{2, Float32}, LineString{2, Float32, Point{2, Float32}, Base.ReinterpretArray{Line{2, Float32}, 1, Tuple{Point{2, Float32}, Point{2, Float32}}, TupleView{Tuple{Point{2, Float32}, Point{2, Float32}}, 2, 1, Vector{Point{2, Float32}}}, false}}, Vector{LineString{2, Float32, Point{2, Float32}, Base.ReinterpretArray{Line{2, Float32}, 1, Tuple{Point{2, Float32}, Point{2, Float32}}, TupleView{Tuple{Point{2, Float32}, Point{2, Float32}}, 2, 1, Vector{Point{2, Float32}}}, false}}}}}, vorn::VoronoiTessellation{Triangulation{Vector{Tuple{Float64, Float64}}, Set{Tuple{Int64, Int64, Int64}}, Int64, Tuple{Int64, Int64}, Set{Tuple{Int64, Int64}}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Tuple{Vector{Int64}, Int64}}, OrderedCollections.OrderedDict{Int64, Vector{Int64}}, OrderedCollections.OrderedDict{Int64, UnitRange{Int64}}, Dict{Int64, DelaunayTriangulation.RepresentativeCoordinates{Int64, Float64}}}, Tuple{Float64, Float64}, Int64, Tuple{Int64, Int64, Int64}, Set{Int64}, Tuple{Int64, Int64}}, bbox::NTuple{4, Float64})
    @ Makie ~/.julia/packages/Makie/VRavR/src/basic_recipes/voronoiplot.jl:112
 [17] (::Makie.var\"#update_plot#849\"{Plot{Makie.voronoiplot, Tuple{VoronoiTessellation{Triangulation{Vector{Tuple{Float64, Float64}}, Set{Tuple{Int64, Int64, Int64}}, Int64, Tuple{Int64, Int64}, Set{Tuple{Int64, Int64}}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Tuple{Vector{Int64}, Int64}}, OrderedCollections.OrderedDict{Int64, Vector{Int64}}, OrderedCollections.OrderedDict{Int64, UnitRange{Int64}}, Dict{Int64, DelaunayTriangulation.RepresentativeCoordinates{Int64, Float64}}}, Tuple{Float64, Float64}, Int64, Tuple{Int64, Int64, Int64}, Set{Int64}, Tuple{Int64, Int64}}}}, Observable{Vector{Polygon{2, Float32, Point{2, Float32}, LineString{2, Float32, Point{2, Float32}, Base.ReinterpretArray{Line{2, Float32}, 1, Tuple{Point{2, Float32}, Point{2, Float32}}, TupleView{Tuple{Point{2, Float32}, Point{2, Float32}}, 2, 1, Vector{Point{2, Float32}}}, false}}, Vector{LineString{2, Float32, Point{2, Float32}, Base.ReinterpretArray{Line{2, Float32}, 1, Tuple{Point{2, Float32}, Point{2, Float32}}, TupleView{Tuple{Point{2, Float32}, Point{2, Float32}}, 2, 1, Vector{Point{2, Float32}}}, false}}}}}}, Observable{Vector{Point{2, Float32}}}})(vorn::VoronoiTessellation{Triangulation{Vector{Tuple{Float64, Float64}}, Set{Tuple{Int64, Int64, Int64}}, Int64, Tuple{Int64, Int64}, Set{Tuple{Int64, Int64}}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Tuple{Vector{Int64}, Int64}}, OrderedCollections.OrderedDict{Int64, Vector{Int64}}, OrderedCollections.OrderedDict{Int64, UnitRange{Int64}}, Dict{Int64, DelaunayTriangulation.RepresentativeCoordinates{Int64, Float64}}}, Tuple{Float64, Float64}, Int64, Tuple{Int64, Int64, Int64}, Set{Int64}, Tuple{Int64, Int64}})
    @ Makie ~/.julia/packages/Makie/VRavR/src/basic_recipes/voronoiplot.jl:211
 [18] plot!(p::Plot{Makie.voronoiplot, Tuple{VoronoiTessellation{Triangulation{Vector{Tuple{Float64, Float64}}, Set{Tuple{Int64, Int64, Int64}}, Int64, Tuple{Int64, Int64}, Set{Tuple{Int64, Int64}}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Tuple{Vector{Int64}, Int64}}, OrderedCollections.OrderedDict{Int64, Vector{Int64}}, OrderedCollections.OrderedDict{Int64, UnitRange{Int64}}, Dict{Int64, DelaunayTriangulation.RepresentativeCoordinates{Int64, Float64}}}, Tuple{Float64, Float64}, Int64, Tuple{Int64, Int64, Int64}, Set{Int64}, Tuple{Int64, Int64}}}})
    @ Makie ~/.julia/packages/Makie/VRavR/src/basic_recipes/voronoiplot.jl:216
 [19] connect_plot!(parent::Scene, plot::Plot{Makie.voronoiplot, Tuple{VoronoiTessellation{Triangulation{Vector{Tuple{Float64, Float64}}, Set{Tuple{Int64, Int64, Int64}}, Int64, Tuple{Int64, Int64}, Set{Tuple{Int64, Int64}}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Tuple{Vector{Int64}, Int64}}, OrderedCollections.OrderedDict{Int64, Vector{Int64}}, OrderedCollections.OrderedDict{Int64, UnitRange{Int64}}, Dict{Int64, DelaunayTriangulation.RepresentativeCoordinates{Int64, Float64}}}, Tuple{Float64, Float64}, Int64, Tuple{Int64, Int64, Int64}, Set{Int64}, Tuple{Int64, Int64}}}})
    @ Makie ~/.julia/packages/Makie/VRavR/src/interfaces.jl:260
 [20] plot!
    @ ~/.julia/packages/Makie/VRavR/src/interfaces.jl:265 [inlined]
 [21] plot!(ax::Axis, plot::Plot{Makie.voronoiplot, Tuple{VoronoiTessellation{Triangulation{Vector{Tuple{Float64, Float64}}, Set{Tuple{Int64, Int64, Int64}}, Int64, Tuple{Int64, Int64}, Set{Tuple{Int64, Int64}}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Tuple{Vector{Int64}, Int64}}, OrderedCollections.OrderedDict{Int64, Vector{Int64}}, OrderedCollections.OrderedDict{Int64, UnitRange{Int64}}, Dict{Int64, DelaunayTriangulation.RepresentativeCoordinates{Int64, Float64}}}, Tuple{Float64, Float64}, Int64, Tuple{Int64, Int64, Int64}, Set{Int64}, Tuple{Int64, Int64}}}})
    @ Makie ~/.julia/packages/Makie/VRavR/src/figureplotting.jl:316
 [22] plot!(fa::Makie.FigureAxis, plot::Plot{Makie.voronoiplot, Tuple{VoronoiTessellation{Triangulation{Vector{Tuple{Float64, Float64}}, Set{Tuple{Int64, Int64, Int64}}, Int64, Tuple{Int64, Int64}, Set{Tuple{Int64, Int64}}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Tuple{Vector{Int64}, Int64}}, OrderedCollections.OrderedDict{Int64, Vector{Int64}}, OrderedCollections.OrderedDict{Int64, UnitRange{Int64}}, Dict{Int64, DelaunayTriangulation.RepresentativeCoordinates{Int64, Float64}}}, Tuple{Float64, Float64}, Int64, Tuple{Int64, Int64, Int64}, Set{Int64}, Tuple{Int64, Int64}}}})
    @ Makie ~/.julia/packages/Makie/VRavR/src/figureplotting.jl:313
 [23] _create_plot(F::Function, attributes::Dict{Symbol, Any}, args::VoronoiTessellation{Triangulation{Vector{Tuple{Float64, Float64}}, Set{Tuple{Int64, Int64, Int64}}, Int64, Tuple{Int64, Int64}, Set{Tuple{Int64, Int64}}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Tuple{Vector{Int64}, Int64}}, OrderedCollections.OrderedDict{Int64, Vector{Int64}}, OrderedCollections.OrderedDict{Int64, UnitRange{Int64}}, Dict{Int64, DelaunayTriangulation.RepresentativeCoordinates{Int64, Float64}}}, Tuple{Float64, Float64}, Int64, Tuple{Int64, Int64, Int64}, Set{Int64}, Tuple{Int64, Int64}})
    @ Makie ~/.julia/packages/Makie/VRavR/src/figureplotting.jl:250
 [24] #voronoiplot#825
    @ ~/.julia/packages/MakieCore/UAwps/src/recipes.jl:175 [inlined]
 [25] top-level scope
    @ ~/Cloud/Hostiso/Projects/RAS_2D/src/mwe.ipynb:2"
}

@DanielVandH
Copy link
Member Author

Thanks for the MWE. I will try and find the time soon to look into it.

@DanielVandH
Copy link
Member Author

I somehow completely forgot about this @CNOT, sorry. I should've re-opened the issue (:.

I can confirm that this issue is still present:

┌ Warning: The triangle (163, 151, 1) has a degenerate circumcenter, (-Inf, -Inf). You may encounter issues with this tessellation. You can disable this warning using toggle_inf_warn!().
└ @ DelaunayTriangulation C:\Users\danjv\.julia\packages\DelaunayTriangulation\FJ3Ab\src\algorithms\voronoi\unbounded.jl:35
┌ Warning: The triangle (256, 205, 2) has a degenerate circumcenter, (-Inf, -Inf). You may encounter issues with this tessellation. You can disable this warning using toggle_inf_warn!().
└ @ DelaunayTriangulation C:\Users\danjv\.julia\packages\DelaunayTriangulation\FJ3Ab\src\algorithms\voronoi\unbounded.jl:35
┌ Warning: The triangle (256, 221, 205) has a degenerate circumcenter, (-Inf, -Inf). You may encounter issues with this tessellation. You can disable this warning using toggle_inf_warn!().
└ @ DelaunayTriangulation C:\Users\danjv\.julia\packages\DelaunayTriangulation\FJ3Ab\src\algorithms\voronoi\unbounded.jl:35
Voronoi Tessellation.
    Number of generators: 266
    Number of polygon vertices: 360
    Number of polygons: 266

This seems to be a really weird case. I am going to very soon have an even better method for computing triangle areas using AdaptivePredicates.jl, so hopefully that fixes it. voronoiplot should probably be skipping over these degenerate cases too..

@DanielVandH
Copy link
Member Author

Your issue will now work once #165 is in @CNOT. Sorry for the delay :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment