tulip-control / polytope

Geometric operations on polytopes of any dimension
https://pypi.org/project/polytope
Other
73 stars 19 forks source link

Rmove or delete particular polytope from a region #84

Open mvnayagam opened 10 months ago

mvnayagam commented 10 months ago

Dear Users and developers,

I have a region with almost 100 polytopes and a reference polytope. I started to compare each of the polytope from the region with the Reference polytope. I want to delete the polytope in the region if it is not in the reference polytope. does the Polytope package offer a short way to do this operation? now i do it as follows

import polyope as PC

oldRegion # --> contains 100 polytope newRegion = [] referencePoly=pc.Polytope(A, b) #--> the reference polytope

for i in oldRegion:

if  i <= referencePoly :
      newRegion.append(i)

the i form the new region as pc.Region([newRegion])

however if there is an option to delete a polytope within the oldRegion on the fly, that would be more helpful.

Any suggestion on this issue, is highly appreciated

Thank you

Muthu Vallinayagam Researcher, Institute of Experimental Physics, TU Freiberg, Germany

necozay commented 10 months ago

I don't remember such functionality existing in the polytope package. What you are doing makes sense to me. The closest would be to do a set difference between the oldRegion and referencePoly but it would result in a different object where the polytopes in the region overlapping with the reference will be clipped (and difference is potentially less efficient as difference of polytopes might not be polytopes themselves and will result in extra polytopes added to your object). However, you can use the code doing the difference (here) as a reference for implementation.