Home > Software design >  How to determine coordinate bounds of the highlighted area
How to determine coordinate bounds of the highlighted area

Time:11-22

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?

highlighted

CodePudding user response:

AREA D & E

  • The line between the areas D and E is made of all the coordinates such that x == y and both x and y are negative, i.e x,y < 0. In other words the equation of the line is f(x)=x
  • From the above information we can deduce that all the coordinates such that x < y and both x and y are negative will belong to the area D.
  • Similarly, all the coordinates such that x > y and both x and y are negative will belong to the area E.

AREA A & B

  • Equation of this line is f(x)=1-x and both x and y are positive, i.e x,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 the y coordinate from the x)
  • From the above information we can deduce that all the coordinates such that y < 1-x and both x and y are positive belongs to area A.
  • And finally, all the coordinates such that y > 1-x and both x and y are positive belongs to area B.
  • Related