SFML community forums

Help => Graphics => Topic started by: ankitpaudel20 on February 08, 2020, 09:18:36 am

Title: Easy method to check if a point is inside of a Rectangle shape
Post by: ankitpaudel20 on February 08, 2020, 09:18:36 am
i want to check for collision detection of rectangle but didn't find a way to check if the point is inside the rectangle so any ideas?
Title: Re: Easy method to check if a point is inside of a Rectangle shape
Post by: eXpl0it3r on February 08, 2020, 10:21:39 am
sf::Rect<T>::contains()

Also you probably can find a few hundred responses by googling "rectangle point collision detection sfml" ;)
Title: Re: Easy method to check if a point is inside of a Rectangle shape
Post by: ankitpaudel20 on February 08, 2020, 11:59:54 am
Isn't that for rectangle whose sides are aligned with axes?

I meant to ask if it had rotations and other transformations applied ?
Title: Re: Easy method to check if a point is inside of a Rectangle shape
Post by: Laurent on February 08, 2020, 05:52:58 pm
Then you can apply the inverse transform of the rectangle to the point, so you're back into a coordinate system where the rectangle is aligned with axes.

Or you can use one of the algorithms which works with any convex shape (Google them).