Page MenuHome

Add generic function to check if polygons are convex
Needs ReviewPublic

Authored by Luca Rood (LucaRood) on Nov 25 2016, 1:47 PM.

Details

Summary

This diff adds a is_poly_convex_v3 function, which will evaluate the convexity of a polygon of any number of sides.

This function is not only generalized for any number of sides, but is also more efficient than the existing is_quad_convex_v3 function, because it skips the unnecessary projection of the vertices onto the normal plane. Even in highly non-planar polygons, the the cross product between adjacent edges will always point to the same side as the normal when the angle is convex, and to the opposite side when concave.

Because of the increased efficiency, I have made is_quad_convex_v3 just call is_poly_convex_v3, instead of doing its own calculations.

Diff Detail

Repository
rB Blender

Event Timeline

Luca Rood (LucaRood) retitled this revision from to Add generic function to check if polygons are convex.
Luca Rood (LucaRood) updated this object.
Luca Rood (LucaRood) set the repository for this revision to rB Blender.

Just some minor cleanup. Btw, kept nr as unsigned int instead of size_t, to keep consistency with the other math functions, especially because this function makes calls such as cross_poly_v3, which doesn't like size_t without casts and stuff...