简体   繁体   中英

Determine winding of a 2D triangles after triangulation

I'm using triangulation code that works pretty well (it processes polygons with holes and integrates with JTS) but apparently it doesn't respect the winding of triangles. Some output triangles are winded one way, some are winded another way.

Is it possible for me to determine and correct the winding of these deviant triangles? Possibly using information from neighbouring triangles, but the simpler the better of course.

For a triangle ABC, you can find the winding by computing the cross product (B - A) x (C - A). For 2d tri's, with z=0, it will only have az component.

To give all the same winding, swap vertices C and B if this z component is negative.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM