Skip to content
Advertisement

How to create a python script that checks if a given point is inside a certain area?

I want to make a python script which checks this, but the point i will be using are (for example) x = 1290 to 1340 and y = 1460 to 1510 (this means that A = 1290 B = 1340 C = 1460 and D = 1510), i have already made a simple script but it needs me to write every single possible coordinate mannualy… here it is:

JavaScript

Anyone has tips to make this either easier or make a total different script?

Advertisement

Answer

Assuming that the sides of the square are parallel to the coordinate axis, you just have to check if the x input is between the limits and that the y input is between the limits. Also, assuming the limits are inclusive (i.e. x == 1290 is inside the square). Thus:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement