What I can tell you is that angles aren't really clockwise at all. Take a look at your friendly unit circle. Angles increment counter-clockwise.
Also, I'm not quite sure what you're trying to do. However, I have a feeling it has something to do with calculating angles from X and Y coordinates--like an ArcTan.
Right? Have you looked at the code for an ArcTan2 lately?
int OID_Atan2(int rise, int run) {
/*Rise is the y-delta, run is the x-delta. */
int t;
if (run == 0)
{
if (rise > 0) return 90;
if (rise < 0) return 270;
else return 0;
}
if (rise == 0)
{
if (run < 0) return 180;
else return 0;
}
t = atan((rise*65536)/run);
if (run > 0 && rise < 0) return t + 360;
if (run < 0) return t + 180;
return t;
}
This isn't commented at all, but anyway. It's the simple code for an ArcTan2, based on what's in the comments at V3 Docs (I can't remember who posted that particular advice, sorry about that).
But, for this to work--since Y actually decrements going up (toward 0 row on the monitor or from the 0, 0, upper left hand corner) instead of incrementing (on a normal cartesian coordinate plane), the Y delta must be reversed.
IE, You've got two points x1, y1, x2, y2.
Angle = Arctan2(y1-y2, x2-x1)
Normally the difference is [second] - [first], but for the Y coordinates you must invert it since screen Y space is sketchy. X space is fine--don't invert it.
Does that make any sense?