c# - Is a line formed by two points greater than 45 degrees off of the horzontal -


I'm trying to figure out that the line defined by two points compared to the horizontal is greater than or equal to 90 degrees . Here is the code I used

  bool moreThan90 = false; Double Angle = Math.At ((Double) (Ending Location Y - Location Y) / (Double) (Ending Location.x - Location.x)); If (angle> Math.PI / 2.0 || angle l = = -Math.PI / 2.0) plus 90 = true;  

Did I do it correctly or what works better. Will it get in the net?

Edit - Actually I have messed up my question to say 45 is not horizontal 90. But the answer came to me at one point where I can understand it (in fact I just got the etan 2 Needs attention).

End of a line more than 90 degrees horizontal, end. Position x. The space will be less than the x value.

So you do not need all the nonsense, it should be enough:

  if (ending location.x  

Edit:

OP means 45 degrees 90, which means that the above simplification no longer holds. For this, it may be better to use Ana 2 (as mentioned by Slux) but in the sense of not using tan:

  if (Math.Ebus (Ending Location.x - Location.x)> Math.Abus (Ending Location. Y - Location .Y) End And Ending Location. X  

Note that you only need a second check if you want only those rows that point to the right


Comments