isConvex returns false for a rotated rectangle

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
Mercurialol
Prole
Posts: 13
Joined: Fri Apr 18, 2014 3:14 pm

isConvex returns false for a rotated rectangle

Post 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
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: isConvex returns false for a rotated rectangle

Post 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.
Mercurialol
Prole
Posts: 13
Joined: Fri Apr 18, 2014 3:14 pm

Re: isConvex returns false for a rotated rectangle

Post by Mercurialol »

I feel stupid. :death: Thanks ;)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest