From what I've gathered, you want the following to hold:
- Horizontal line:
P1 -------- P2 => 0°
- Horizontal line:
P2 -------- P1 => 180°
Rotating the horizontal line clockwise
You said, you want the angle to increase in clockwise direction.
Rotating this line P1 -------- P2 such that P1 is above P2, the angle must thus be 90°.
If, however, we rotated in the opposite direction, P1 would be below P2 and the angle is -90° or 270°.
Working with atan2
Basis: Considering P1 to be the origin and measuring the angle of P2 relative to the origin, then P1 -------- P2 will correctly yield 0.
float xDiff = x2 - x1;
float yDiff = y2 - y1;
return Math.Atan2(yDiff, xDiff) * 180.0 / Math.PI;
However, atan2 let's the angle increase in CCW direction.
Rotating in CCW direction around the origin, y goes through the following values:
- y = 0
- y > 0
- y = 0
- y < 0
- y = 0
This means, that we can simply invert the sign of y to flip the direction. But because C#'s coordinates increase from top to bottom, the sign is already reversed when computing yDiff.