JuliaGeometry / JuliaGeometry/PolygonOps.jl
API to handle polygons with holes
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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