Welcome,
Guest
. Please
login
or
register
. Did you miss your
activation email?
French forum
Home
Help
Search
Login
Register
SFML community forums
»
Help
»
Graphics
»
Easy method to check if a point is inside of a Rectangle shape
Print
Pages: [
1
]
Author
Topic: Easy method to check if a point is inside of a Rectangle shape (Read 2361 times)
0 Members and 1 Guest are viewing this topic.
ankitpaudel20
Newbie
Posts: 5
Easy method to check if a point is inside of a Rectangle shape
«
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?
Logged
eXpl0it3r
SFML Team
Hero Member
Posts: 11034
Re: Easy method to check if a point is inside of a Rectangle shape
«
Reply #1 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"
Logged
Official FAQ:
https://www.sfml-dev.org/faq.php
Official Discord Server:
https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog:
https://duerrenberger.dev/blog/
ankitpaudel20
Newbie
Posts: 5
Re: Easy method to check if a point is inside of a Rectangle shape
«
Reply #2 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 ?
Logged
Laurent
Administrator
Hero Member
Posts: 32498
Re: Easy method to check if a point is inside of a Rectangle shape
«
Reply #3 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).
Logged
Laurent Gomila - SFML developer
Print
Pages: [
1
]
SFML community forums
»
Help
»
Graphics
»
Easy method to check if a point is inside of a Rectangle shape