Conversation
Benchmark Results (Julia vlts)Time benchmarks
Memory benchmarks
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1328 +/- ##
==========================================
+ Coverage 85.44% 85.87% +0.43%
==========================================
Files 198 200 +2
Lines 6402 6513 +111
==========================================
+ Hits 5470 5593 +123
+ Misses 932 920 -12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Benchmark Results (Julia v1)Time benchmarks
Memory benchmarks
|
|
@souma4 what is the status of this one? Is it ready for review? |
src/hulls/concave.jl
Outdated
| """ | ||
| struct Concave <: HullMethod end | ||
|
|
||
| function hull(points, ::Concave; k=3) |
There was a problem hiding this comment.
Notice that the design we follow is one in which every parameter of the method is stored in the method object itself. The k parameter should be a field of the Concave struct. Also, try to be more specific with the method name, perhaps KnnJarvisMarch?
Can't we adjust our current JarvisMarch to include a k parameter instead of repeating a similar implementation?
There was a problem hiding this comment.
As far as your first suggestion, that's easy to swap in.
For the second, Jarvis March works by performing a global ordering of points by "right hand turns." What do you think of making a more generic JarvisHull that can be used to dispatch the k-th jarvis march algorithm, but KnnJarvisMarch is a type that defaults to k=3, and JarvisMarch is just a method dispatch for hull where points are used to set k?
Something to the effect of
abstract type JarvisHull <: HullMethod end # I can see removing this and Making Knn JarvisMarch a subtype of HullMethod. That would avoid introducing a new abstract type. Just might make reduce extensibility.
struct JarvisMarch <: JarvisHull end
struct KnnJarvisMarch <: JarvisHull
k::Int
KnnJarvisMarch() = new(3)
KnnJarvisMarch(k::Int) = new(k)
end
function hull(points, method::J) where J <: JarvisHull #if we remove the abstract type, then just replace J with the concrete type
# k-nearest implementation that I propose
# ...
end
hull(points, ::JarvisMarch) = hull(points, KnnJarvisMarch(length(points))
Let me know what you think
There was a problem hiding this comment.
I would keep it as simple as possible. From what I can tell we only need to generalize the implementation of JarvisMarch to handle k. By default we can set k=nothing and update it inside the hull call to match the current behavior. If the generalization to handle k implies worst performance when k=npoints, then we can consider alternative designs.
|
@juliohm I still want to simplify the internal logic. The check for self intersection is a bit messy right now so I don't think it's ready. And with your other feedback, it might be worth slotting this Knn approach into |
…rather than separate concave method
|
@juliohm This should be good for review now. I refactored the main jarvis algorithm to dispatch on different |
|
Thank you @souma4. I will try to find some time to review the PR over the week. |
Implementing a k nearest neighbors approach for Concavehulls #497. The paper referenced in the issue is primarily for combining offset points and is quite a bit more involved than this paper. This looks very similar to Jarvis March, just with an added check to prevent self intersections. I refactored some of the convex hull tests to make sure we are properly testing hulls in general, but not holding concave hulls to the same standard as convex hulls.
I am curious, though, The tests starting at L43 and L75 give different polygons between concave and convex hulls. The convex hull hugs tightly to the points, but the concave hull smooths them. To me it seems like a valid solution (plus, concave hulls don't have a singular correct solution), but it seems sort of weird that the area of the convex hull is less than the area of the concave hull. Let me know what you think.
edit: Ah, I didn't catch it's just defaulting to convex hull because it fails to get some points inside the polygon. More work to be done. Will mark for review when it gets solved