I have the area like in the below. I am generating random coordinates between this coordinate map. When the randomly generated number comes (0.3,-0.3) I did easily program that it recognizes this coordinate belongs to Area F but how can I determine the bounds of A / B / D / E to recognize if the randomly generated coordinate belongs to these areas? What are the bounds of Area E for writing an if statement to recognize if randomly generated coordinate inside of it?
CodePudding user response:
AREA D
& E
- The line between the areas
D
andE
is made of all the coordinates such thatx == y
and bothx
andy
are negative, i.ex,y < 0
. In other words the equation of the line isf(x)=x
- From the above information we can deduce that all the coordinates such that
x < y
and bothx
andy
are negative will belong to the areaD
. - Similarly, all the coordinates such that
x > y
and bothx
andy
are negative will belong to the areaE
.
AREA A
& B
- Equation of this line is
f(x)=1-x
and bothx
andy
are positive, i.ex,y > 0
(which you can easily deduce yourself if you take few coordinates that belongs to this line and try to figure out how you will get they
coordinate from thex
) - From the above information we can deduce that all the coordinates such that
y < 1-x
and bothx
andy
are positive belongs to areaA
. - And finally, all the coordinates such that
y > 1-x
and bothx
andy
are positive belongs to areaB
.