Skip to content

[BUG]: Clipped Polygon must be CCW for Voronoi #229

@skygering

Description

@skygering

Describe the bug

In the case below, the clipping polygon only works if the boundary is CCW, which isn't in the documentation.

Reproducer

using DelaunayTriangulation
using Random
using CairoMakie

rng = Xoshiro(0)

points = [(0.25, 0.25), (0.75, 0.25), (0.75, 0.75), (0.25, 0.75), (0.5, 0.5)]
boundary1 = (((0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0), (0.0, 0.0)), (1, 2, 3, 4, 1))
boundary2 = (((0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 1.0), (0.0, 0.0)), (1, 2, 3, 4, 1))

tri = triangulate(points; rng)
vorn1 = voronoi(tri, clip = true, clip_polygon = boundary1)
voronoiplot(vorn1)

vorn2 = voronoi(tri, clip = true, clip_polygon = boundary2)
voronoiplot(vorn2)

For boundary1, I get the following:

Image

while for boundary2, I get the correct result:

Image

Environment information

Post the result of doing

using InteractiveUtils
versioninfo()
Julia Version 1.11.5
Commit 760b2e5b739 (2025-04-14 06:53 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin24.0.0)
  CPU: 8 × Apple M3
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, apple-m2)
Threads: 1 default, 0 interactive, 1 GC (on 4 virtual cores)
Environment:
  JULIA_PKG_USE_CLI_GIT = true

and

using Pkg
Pkg.status()
julia> Pkg.status()
Project GeometryOps v0.1.30
Status `~/.julia/dev/GeometryOps/Project.toml`
  [1520ce14] AbstractTrees v0.4.5
  [35492f91] AdaptivePredicates v1.2.0
  [150eb455] CoordinateTransformations v0.6.4
  [9a962f9c] DataAPI v1.16.0
  [927a84f5] DelaunayTriangulation v1.6.4
  [429591f6] ExactPredicates v2.2.9
  [411431e0] Extents v0.1.6
  [68eda718] GeoFormatTypes v0.4.4
  [cf35fbd7] GeoInterface v1.6.0
  [05efe853] GeometryOpsCore v0.1.7
  [746ee33f] SortTileRecursiveTree v0.1.4
  [90137ffa] StaticArrays v1.9.15
  [10745b16] Statistics v1.11.1
  [bd369af6] Tables v1.12.1
  [37e2e46d] LinearAlgebra v1.11.0
  [9a3f8284] Random v1.11.0

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