Polygon Intersections

조회 수: 4 (최근 30일)
Romain W
Romain W 2012년 3월 13일
댓글: jahanzaib ahmad 2019년 1월 1일
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

답변 (1개)

Image Analyst
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.
  댓글 수: 2
Romain W
Romain W 2012년 3월 13일
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.
jahanzaib ahmad
jahanzaib ahmad 2019년 1월 1일

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by