Page 1 of 1

isConvex returns false for a rotated rectangle

Posted: Tue Aug 12, 2014 9:30 pm
by Mercurialol
Drawing a rotated rectangle as a polygon is missing one side. It's a simple polygon, but math.isConvex returns false, even though it's a perfectly rotated rectangle (by 45 degrees). Any ideas ?

Code: Select all

love.graphics.setColor(255, 80, 0)
love.graphics.polygon('fill', 320, 0, 350, 30, 280, 40, 310, 70)
Image

Thanks in advance

Mercurial

Re: isConvex returns false for a rotated rectangle

Posted: Wed Aug 13, 2014 1:15 am
by Ref
It's because your polygon is NOT convex (not even a valid polygon)!
Try interchanging the last two points.

Code: Select all

love.graphics.polygon('fill', 320, 0, 350, 30, 310, 70, 280, 40)
Just if you haven't already figured this out.

Re: isConvex returns false for a rotated rectangle

Posted: Wed Aug 13, 2014 6:49 am
by Mercurialol
I feel stupid. :death: Thanks ;)