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,