Angles (geometric), normalization and conversion: Difference between revisions
Content added Content deleted
Alpha bravo (talk | contribs) (Added AutoHotkey) |
|||
Line 230: | Line 230: | ||
1000000.0000000 5.9256211 339.5130823 377.2367581 6035.7881302 |
1000000.0000000 5.9256211 339.5130823 377.2367581 6035.7881302 |
||
</pre> |
</pre> |
||
=={{header|AutoHotkey}}== |
|||
<lang AutoHotkey>testAngles := [-2, -1, 0, 1, 2, 6.2831853, 16, 57.2957795, 359, 399, 6399, 1000000] |
|||
result .= "Degrees Degrees Gradians Mils Radians`n" |
|||
for i, a in testAngles |
|||
result .= a "`t" Deg2Deg(a) "`t" Deg2Grad(a) "`t" Deg2Mil(a) "`t" Deg2Rad(a) "`n" |
|||
result .= "`nGradians Degrees Gradians Mils Radians`n" |
|||
for i, a in testAngles |
|||
result .= a "`t" Grad2Deg(a) "`t" Grad2Grad(a) "`t" Grad2Mil(a) "`t" Grad2Rad(a) "`n" |
|||
result .= "`nMills Degrees Gradians Mils Radians`n" |
|||
for i, a in testAngles |
|||
result .= a "`t" Mil2Deg(a) "`t" Mil2Grad(a) "`t" Mil2Mil(a) "`t" Mil2Rad(a) "`n" |
|||
result .= "`nRadians Degrees Gradians Mils Radians`n" |
|||
for i, a in testAngles |
|||
result .= a "`t" Rad2Deg(a) "`t" Rad2Grad(a) "`t" Rad2Mil(a) "`t" Rad2Rad(a) "`n" |
|||
MsgBox, 262144, , % Clipboard := TabAlign(result) |
|||
return |
|||
;------------------------------------------------------- |
|||
Deg2Deg(Deg){ |
|||
return Mod(Deg, 360) |
|||
} |
|||
Deg2Grad(Deg){ |
|||
return Deg2Deg(Deg) * 400 / 360 |
|||
} |
|||
Deg2Mil(Deg){ |
|||
return Deg2Deg(Deg) * 6400 / 360 |
|||
} |
|||
Deg2Rad(Deg){ |
|||
return Deg2Deg(Deg) * (π:=3.141592653589793) / 180 |
|||
} |
|||
;------------------------------------------------------- |
|||
Grad2Grad(Grad){ |
|||
return Mod(Grad, 400) |
|||
} |
|||
Grad2Deg(Grad){ |
|||
return Grad2Grad(Grad) * 360 / 400 |
|||
} |
|||
Grad2Mil(Grad){ |
|||
return Grad2Grad(Grad) * 6400 / 400 |
|||
} |
|||
Grad2Rad(Grad){ |
|||
return Grad2Grad(Grad) * (π:=3.141592653589793) / 200 |
|||
} |
|||
;------------------------------------------------------- |
|||
Mil2Mil(Mil){ |
|||
return Mod(Mil, 6400) |
|||
} |
|||
Mil2Deg(Mil){ |
|||
return Mil2Mil(Mil) * 360 / 6400 |
|||
} |
|||
Mil2Grad(Mil){ |
|||
return Mil2Mil(Mil) * 400 / 6400 |
|||
} |
|||
Mil2Rad(Mil){ |
|||
return Mil2Mil(Mil) * (π:=3.141592653589793) / 3200 |
|||
} |
|||
;------------------------------------------------------- |
|||
Rad2Rad(Rad){ |
|||
return Mod(Rad, 2*(π:=3.141592653589793)) |
|||
} |
|||
Rad2Deg(Rad){ |
|||
return Rad2Rad(Rad) * 180 / (π:=3.141592653589793) |
|||
} |
|||
Rad2Grad(Rad){ |
|||
return Rad2Rad(Rad) * 200 / (π:=3.141592653589793) |
|||
} |
|||
Rad2Mil(Rad){ |
|||
return Rad2Rad(Rad) * 3200 / (π:=3.141592653589793) |
|||
} |
|||
;-------------------------------------------------------</lang> |
|||
{{out}} |
|||
<pre>Degrees Degrees Gradians Mils Radians |
|||
-2 -2 -2.222222 -35.555556 -0.034907 |
|||
-1 -1 -1.111111 -17.777778 -0.017453 |
|||
0 0 0.000000 0.000000 0.000000 |
|||
1 1 1.111111 17.777778 0.017453 |
|||
2 2 2.222222 35.555556 0.034907 |
|||
6.2831853 6.283185 6.981317 111.701072 0.109662 |
|||
16 16 17.777778 284.444444 0.279253 |
|||
57.2957795 57.295780 63.661977 1018.591636 1.000000 |
|||
359 359 398.888889 6382.222222 6.265732 |
|||
399 39 43.333333 693.333333 0.680678 |
|||
6399 279 310.000000 4960.000000 4.869469 |
|||
1000000 280 311.111111 4977.777778 4.886922 |
|||
Gradians Degrees Gradians Mils Radians |
|||
-2 -1.800000 -2 -32.000000 -0.031416 |
|||
-1 -0.900000 -1 -16.000000 -0.015708 |
|||
0 0.000000 0 0.000000 0.000000 |
|||
1 0.900000 1 16.000000 0.015708 |
|||
2 1.800000 2 32.000000 0.031416 |
|||
6.2831853 5.654867 6.283185 100.530965 0.098696 |
|||
16 14.400000 16 256.000000 0.251327 |
|||
57.2957795 51.566202 57.295780 916.732472 0.900000 |
|||
359 323.100000 359 5744.000000 5.639159 |
|||
399 359.100000 399 6384.000000 6.267477 |
|||
6399 359.100000 399 6384.000000 6.267477 |
|||
1000000 0.000000 0 0.000000 0.000000 |
|||
Mills Degrees Gradians Mils Radians |
|||
-2 -0.112500 -0.125000 -2 -0.001963 |
|||
-1 -0.056250 -0.062500 -1 -0.000982 |
|||
0 0.000000 0.000000 0 0.000000 |
|||
1 0.056250 0.062500 1 0.000982 |
|||
2 0.112500 0.125000 2 0.001963 |
|||
6.2831853 0.353429 0.392699 6.283185 0.006169 |
|||
16 0.900000 1.000000 16 0.015708 |
|||
57.2957795 3.222888 3.580986 57.295780 0.056250 |
|||
359 20.193750 22.437500 359 0.352447 |
|||
399 22.443750 24.937500 399 0.391717 |
|||
6399 359.943750 399.937500 6399 6.282204 |
|||
1000000 90.000000 100.000000 1600 1.570796 |
|||
Radians Degrees Gradians Mils Radians |
|||
-2 -114.591559 -127.323954 -2037.183272 -2.000000 |
|||
-1 -57.295780 -63.661977 -1018.591636 -1.000000 |
|||
0 0.000000 0.000000 0.000000 0.000000 |
|||
1 57.295780 63.661977 1018.591636 1.000000 |
|||
2 114.591559 127.323954 2037.183272 2.000000 |
|||
6.2831853 360.000000 400.000000 6399.999993 6.283185 |
|||
16 196.732472 218.591636 3497.466173 3.433629 |
|||
57.2957795 42.806349 47.562610 761.001765 0.747112 |
|||
359 49.184845 54.649828 874.397248 0.858437 |
|||
399 181.016026 201.128917 3218.062679 3.159326 |
|||
6399 155.693104 172.992338 2767.877408 2.717357 |
|||
1000000 339.513082 377.236758 6035.788130 5.925621</pre> |
|||
=={{header|AWK}}== |
=={{header|AWK}}== |