c++ - the efficient algorithm for finding the area of polygon -
i looking best (efficient algorithm calculating area of 2d polygon (especially triangle given 3 points). search on web , found following link, still i'm not sure efficient in terms of memory cost or not (since mesh huge). wondering if there tricks in c++ (i'm newbie in c++) applied on them:
here links:
(stackoverflow) how determine if point in 2d triangle?
http://www.softwareandfinance.com/visual_cpp/triangle_area_perimeter.html
it's worth mention final target find out if point inside (not on border) polygon.
thanks help.
joachim pileborg suggested in comments area isn't needed, misses point: there's efficient algorithm require intermediate value, happens 2*area
.
however, in case problem input domain: mesh of triangles. means every vertex borders on 2 triangles. it's not "point p lies on left of edge e, it's not in triangle t". there large set of triangles ti, of lie on left, of lie on right, , 1 directly on either side of given edge.
given complexity, should pre-process mesh. partition in manageable chunks, e.g. 16x16, , note each triangle in chunks lies. point p lies in 1 chunk, need test perhaps 1% of triangles (a single triangle may lie in multiple chunks, average low).
(you if ever need single point-to-mesh match, preprocessing justified. , pre-calculate area while you're @ it.)
Comments
Post a Comment