I am working on an assignment in which we are given a (my_x,my_y) coordinate and we have to tell whether this coordinate lies in the free space or inside an obstacle.
As you can see, from the picture, I have to tell whether a certain point lies among any of the obstacle.
Checking for out of boundary is easy and simple. Similarly I check for circle as (pseudo code):
if sqrt((my_x-5)^2+(my_y-3.5)^2) <= 0.5
this means it is inside circle.
if ((my_x >= 3.5 || my_x <= 6.5) && ((my_y >= 5 || my_y <= 6)
this means it is inside rectangle.
However I am stuck for the triangle case. The main reason is that my_x and my_y are of decimal type and can take any value suppose up to 2 decimal figures. Now one was is to have several if conditions and then check each.
I want to know is there is some better algorithm to define the triangle may be using equations and what it might be.