Reputation: 481
I am calculating Euclidian distance between points in an Excel application, and also need to be able to specify the direction of the difference in two-dimensional location for each pair of points.
Does anyone know how to implement this in Excel?
Below is a simplified illustration of my current Euclidian distance calculation. I have two points, and calculate how far apart Point1 is from Point2. But I would also like to find the direction (in degrees preferably) between Point1 and Point2.
Upvotes: 0
Views: 2590
Reputation: 52008
For direction, you could use the angle that the vector from point one to point two makes with respect to the positive x axis:
=DEGREES(ATAN2(B3-B2,C3-C2))
this will return a number between -180 and +180 degrees. The ATAN2
function is given by ATAN2(x,y) = arctan(y/x)
with the refinement that it returns pi/2 rather than a division by 0 error if x = 0 and also gives an answer in the appropriate quadrant.
Upvotes: 3