Is a line formed by two points greater than 90 degrees off of the horzontal.

Posted by Scott Chamberlain on Stack Overflow See other posts from Stack Overflow or by Scott Chamberlain
Published on 2010-05-17T15:51:20Z Indexed on 2010/05/17 16:00 UTC
Read the original article Hit count: 240

Filed under:
|
|

I am trying to find out if a line defined by two points is greater than or equal to 90 degrees compared to the horizontal. Here is the code I used

bool moreThan90 = false;
double angle = Math.Atan((double)(EndingLocation.Y - Location.Y) / (double)(EndingLocation.X - Location.X));
if (angle >= Math.PI / 2.0 || angle <= -Math.PI / 2.0)
    moreThan90 = true;

Did I do this correctly or is there a better built in function in .Net that will find this?

© Stack Overflow or respective owner

Related posts about c#

Related posts about math