I wouldn't imagine that there is a library method for finding the angle between the two vectors, you doing this correctly (the math is right) and a quick glance around msdn and google didn't provide me with anything. I would use SLaks' version of calling the Math.Atan
method.
An interesting thing to note since you are using the 'horizontal' as your plane to determine if the angle is greater than 90 degrees. If endingLocation.x < Location.X your angle will always be 'greater' than 90 degrees, if you are measuring from the positive X-Axis.
Edit:
Original question was changed to 45 degree check.
The section below is a discussion of how to do this without doing floating point division per a comment that the OP made.
To find out if you have a 45 degree angle we know a few things without actually having to call ATan
on the points.
first the slope of a 45 degree angle is 1. So if
Math.Abs((EndLocation.y - location.y)/(EndLocation.X - Location.X)) > 1
You have an angle that is > 45 degrees, however as permutations of a 45 degree angle occur 4 times in a circle. We need to check a few things.
If EndLocation.X < Location.X
then the angle is greater than 45 degrees. This represents all angles that are left of the Y Axis (90 - 270). To determine if the angle is greater than 45 degrees we only need to know if the absolute value of the slope is greater than 1. This will always be true for the following.
Math.Abs(EndLocation.Y - Location.Y) > Math.Abs(EndLocation.X - Location.X)
.
So with a if statement following something like
If (EndLocation.X < Location.X) OrElse (Math.Abs(EndLocation.Y - Location.Y) > Math.Abs(EndLocation.X - Location.X) Then AngleGreaterThan45 = True.
We can determine if the angle is greater than 45 degrees without the need to perform any floating point calculations.