Polygon Intersections

4 views (last 30 days)
Romain W
Romain W on 13 Mar 2012
Commented: jahanzaib ahmad on 1 Jan 2019
Hi everyone,
I actually have to compute intersections between thousands of 2D triangles and I found the function "Polygons_intersection" on the File Exchange. My only (and significant) problem is that it takes an infinite amount of time to perform the task,I was wondering if there would be a way to improve greatly the computational time of the algorithm? I really need quickly such a function working at enhanced speed.
Also, do you have any other idea on how to find the intersection of 2D triangles using matlab built-in functions?
Context: basically,what's behind my code is a simple flow solver. My algorithm starts by importing an ".stl" file (from whatever CAD program) within Matlab in terms of faces (f) and vertices (v). This helps me to define a mesh made up of triangle elements that follows the surface of my 3D model. After working through the mesh, and depending on the freestream velocity, I need to determine which of the triangle element is impacted by the rectilinear flow.
To do so, I define a new reference frame based on the freestream velocity vector,I calculate the vertices in this new reference frame,projects my vertices in a plane whose normal is the velocity vector and I want to determine the intersection between the triangles on the plane and determines which of the triangle is the foremost to keep only that one and remove the obstructed ones (once again depending on the flow direction).
Thanks a lot for you help,
Romain

Answers (1)

Image Analyst
Image Analyst on 13 Mar 2012
Sure, if you're willing to do it numerically (i.e. with 2D arrays, which can be considered images) instead of analytically (using vertex coordinates and having to solve analytical equations to find out exactly where the lines cross). There would be some quantization error but maybe that doesn't matter, especially if you're already dealing with digitized images. You can use normal logical operators, like
intersectionImage = image1 & image2;
assuming image1 and image2 are binary (logical) images that define where the triangles are.
  2 Comments
Romain W
Romain W on 13 Mar 2012
thank you very much for your answer. But I don't think it would suit my application,I've added a small description within my original question so as to clarify what my algorithm needs to perform.

Sign in to comment.

Products

Community Treasure Hunt

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

Start Hunting!