Original Post
Hallo, How can I check if a point is inside a rectangle? The rectangle has been rotated, so I cant simply compare the point to the vertexes (I think). Thanks in advance
Quote:Short answer: transform the point into the local space of the rectangle, and then perform a point-in-axis-aligned-rectangle test (which is straightforward).
Original post by h3ro
Hallo,
How can I check if a point is inside a rectangle? The rectangle has been rotated, so I cant simply compare the point to the vertexes (I think).
Thanks in advance
Quote:
Original post by h3ro
Sorry for being dump here, but could you please explain a bit more? Math is not really my strongest side. Tried google, but couldnt find anything for "point-in-axis-aligned-rectangle test"
bool Inisde( x, y, l, r, b, t )//x,y are the point, l,r,b,t are the extents of the rectangle{ return x > l && x < r && y > b && y < t;}Quote:
Original post by h3ro
Thank you to all of you. I have it working now :)
Quote:Just for the record, the solution proposed by alvaro is the same as the one I proposed in the first reply to your thread (alvaro, however, was kind enough to spell out the details for you :).
Original post by h3ro
I used yours. It was the simplest and the I understood it :P
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more