harveydevereux / AlphaShapes.jl

Basic implementation of alpha shapes
MIT License
8 stars 3 forks source link

Polyhedra integration #4

Open harveydevereux opened 2 years ago

harveydevereux commented 2 years ago

Great thanks, I'll take a look in a second.

Just had a look at Polyhedra.jl, looks like workflow would be Vertices::Array{Float64,3} -> "convex hull points" -> Polyhedra::vrep for both shapes then it should just be a call to intersect(P1,P2) like this example from their docs. Have not used Polyhedra myself so could be wrong.

# two hard coded polygons
P1 = polyhedron(vrep([
    -1.9 -1.7
    -1.8  0.5
     1.7  0.7
     1.9 -0.3
     0.9 -1.1
]), lib)

P2 = polyhedron(vrep([
    -2.5 -1.1
    -0.8  0.8
     0.1  0.9
     1.8 -1.2
     1.3  0.1
]), lib)

Pint = intersect(P1, P2) # the intersection shape

If this is the case it should be simple..

Originally posted by @harveydevereux in https://github.com/harveydevereux/AlphaShapes.jl/issues/2#issuecomment-1014388752

itsdfish commented 2 years ago

Integrating with Polyhedra seems like a good idea because it does not have alpha shapes to deal with shapes that might be concave.

As a disclaimer, I must admit that I am far from an expert in geometry. Nonetheless, I was wondering if there is a more general approach to identifying an intersection between shapes that can be some combination of convex and concave? If I understand correctly, the proposal above would only apply to the special case in which the shapes are convex. The restriction that the shapes must be convex is one of the biggest limitations in Polyhedra.

harveydevereux commented 2 years ago

I think you may be right, I'm far from an expert in this area myself.

I'll have to familiarise myself with Polyhedra.jl and maybe open an issue asking about non-convex shapes.

I did find some articles on arbitrary polytope intersections so it might be doable but beyond me without more careful reading https://link.springer.com/article/10.1007/s00454-008-9097-3 https://www.sciencedirect.com/science/article/abs/pii/0378475490900032 - downloaded this one, and it does have pseudo-code

itsdfish commented 2 years ago

I am willing to help in cases where I can, but I suspect someone at Polyhedra would be better suited to assist in terms of the math and the software design.