Managing Active Directory does not always have to be complicated. If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Starting point is p1

Ending point is p2

Angle is measured anticlockwise

0 degrees is straight right

Pseudocode example:

// First You calculate distances (must be in signed variables)

dx=x2-x1

dy=y2-y1

// If x part is 0 You could get into division by zero problems, but in that case result can only be 90 or 270:

if dx=0 {

if dy > 0

result = 90

else

result = 270

}

else {

// otherwise angle is determined as inverse tangent of coordinates

result = (atan(dy / dx)) * 180 / pi

}

// the *180 / pi part is because results are usualy in radians, but You wanted it in degrees

// this is only valid for two quadrants (for right side of the coordinate system) so modify result:

if dx < 0 {

result = result + 180

}

// looks better if all numberes are positive (0 to 360 range)

if result < 0 {

result = result + 360

}