Polygon Intersections
5 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
Image Analyst
2012-3-13
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!