CSharp ConvertVectorToAngle
From scripting
static double ConvertVectorToAngle(double x, double y) { double WinAngle = 0.0; if (x == 0.0) { if (y > 0) { WinAngle = 90.0; } else { WinAngle = 270.0; } } else { WinAngle = Math.Abs(Math.Atan(Math.Abs(y) / Math.Abs(x))) * 180.0 / Math.PI; if ((x >= 0) && (y >= 0)) { //WinAngle = WinAngle; } else if ((x < 0) && (y >= 0)) { WinAngle = 180.0 - WinAngle; } else if ((x < 0) && (y < 0)) { WinAngle = WinAngle + 180.0; } else { WinAngle = 360.0 - WinAngle ; } } return WinAngle; }
This subroutine was used in the development of the Mega-Dots World's Toughest Connect-the-Dots Puzzles.
Unrelated MEL scripting help located here: YSYT.