Faster polygon operations than polyshape

Is there a faster method to handle vast amounts of polyshape operations? In my thesis, I need to perform large number of boolean operations of FoV of multiple satellites. I tried using a MEX version of GPC-Library. Though individual operations (binary operations with just two polygons) seemed faster, when working with polygon vectors, polyshape again become comparable in performance. Besides this the MEX code also become unstable and crashes MATLAB as I call it repeatedly. Any suggestions would be appriceated.
P.s. I use polyshape due to level of accuracy required for work, instead of approximated spherical point and operations on them.

1 Comment

@JackCrusoe47 I am looking for ways to speed up my polyshape operations too. Do you have a rough estimate on the kind of time savings you got with the code you were using?

Sign in to comment.

Answers (1)

5 Comments

Thank you.
In then end I used a modified version of Angus J's code too.
I used : New Polygon Clipping and Offsetting by Erik Johnson and then modified it allow multiple boolean operation and hole definition closely resembling Polygon Clipper - Sebastian Hölz method. I needed to use all the functionalities of polyshape (diff, intersect, xor and union + overlaps and isinterior (I used the mex version of INPOLYGON - Bruno Luong ).
As you can probably guess, I'm still not used to writing my own mex function builds (except using Matlab coder).
@ Bruno Luong . Sorry. I should thank you also for your function, Inpolygon. I didn't realisize it was your code. I was able to speed up several parts of my thesis using your function. Thank you.
Ah your are welcome. I'm glad to learn the code is helpful.
Tian Dong
Tian Dong on 28 Apr 2022
Edited: Tian Dong on 28 Apr 2022
Hi Bruno,
I hope this message find you well. I came across this thread as I was searching for a way to speed up union polyshapes. I am putting polybuffer around a set of links (see figure below). Method 1(left figure): store XY coordinates of all links in one array, then make a polyshape. output is not ideal. Method 2 (right figure): generate a polyshape for each link, then union. output is very ideal, but about 20 times slower than Method 1. I wonder if you can help me out here. Thank you.
In term of the clipper software, do I need to write a MEX Function based on C++ or C# to translate the software to use it in MATLAB, how would the outputs from software work with polyshape in MATLAB? I do not have any experenice in C languages or wrting MEX. any tipps there? Thank you so much.
The clipper provide a mex-ready cpp file. All you need is the C compiler supported by your MATLAB version.
The package is provided with an mfile with H1 line. The calling is well documented.

Sign in to comment.

Categories

Products

Release

R2020b

Asked:

on 6 Dec 2020

Commented:

on 20 Jun 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!