JuliaGeometry / JuliaGeometry/PolygonOps.jl

API to handle polygons with holes

Open
#12 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
22
Forks
4
PR merge metrics
No merged PRs in 30d

Description

Hello,

The paper is a bit unclear, but the Algorithm 1 cited there holds only for actual rings, not whole polygons by their definition.
To have proper support for holes one would need to calculate the parity for each hole and aggregate that

Namely we would only need to do something along the lines of:

function inpolyholes(p, rings...; in::T=1, on::T=-1, out::T=0) where {T}

    outerring = first(rings)
    innerrings = Base.tail(rings)

    res = inpolygon(p, outerring; in, on, out)

    isempty(innerrings) && return res

    k = 0
    res == in && (k += 1)

    for ring in innerrings
        ringres = inpolygon(p, ring; in, on, out)
        if ringres == on && (ringres != in && ringres != out) # to properly handle the case where on is equal to either in or out.
            return on
        end

        ringres == in && ( k += 1 )
    end

    iszero(k % 2) && return out
    return in
end

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the existing inpolygon API and the cited Algorithm 1, then trace how rings are currently represented and tested. Add a polygon-with-holes entry point that aggregates the outer ring and inner-ring results by parity, including the stated boundary-value behavior; done means points inside, outside, and on holes return the expected values.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
computer-graphics
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.