Angles (geometric), normalization and conversion: Difference between revisions
Content added Content deleted
(BBC BASIC entry.) |
(Added Akgol 68) |
||
Line 217: | Line 217: | ||
Radians Normalized Degrees Gradians Mils |
Radians Normalized Degrees Gradians Mils |
||
─────────────────────────────────────────────────────────────────────────────────── |
─────────────────────────────────────────────────────────────────────────────────── |
||
-2.0000000 -2.0000000 -114.5915590 -127.3239545 -2037.1832716 |
|||
-1.0000000 -1.0000000 -57.2957795 -63.6619772 -1018.5916358 |
|||
0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 |
|||
1.0000000 1.0000000 57.2957795 63.6619772 1018.5916358 |
|||
2.0000000 2.0000000 114.5915590 127.3239545 2037.1832716 |
|||
6.2831853 6.2831853 359.9999996 399.9999995 6399.9999927 |
|||
16.0000000 3.4336294 196.7324722 218.5916358 3497.4661726 |
|||
57.2957795 0.7471117 42.8063493 47.5626103 761.0017647 |
|||
359.0000000 0.8584375 49.1848452 54.6498280 874.3972479 |
|||
399.0000000 3.1593256 181.0160257 201.1289175 3218.0626795 |
|||
6399.0000000 2.7173573 155.6931042 172.9923380 2767.8774082 |
|||
1000000.0000000 5.9256211 339.5130823 377.2367581 6035.7881302 |
|||
</pre> |
|||
=={{header|ALGOL 68}}== |
|||
{{Trans|11l}} |
|||
<syntaxhighlight lang="algol68"> |
|||
BEGIN # Angles (geometric), normalization and conversion - translated from the 11l sample # |
|||
[]REAL values = ( -2, -1, 0, 1, 2, 6.2831853, 16, 57.2957795, 359, 399, 6399, 1000000 ); |
|||
PROC norm = ( REAL x, y )REAL: |
|||
BEGIN |
|||
INT n = ENTIER ( ABS x / ABS y ); |
|||
REAL r := x - ( n * y ); |
|||
r |
|||
END # norm # ; |
|||
PROC normd = ( REAL x )REAL: norm( x, 360 ); |
|||
PROC normg = ( REAL x )REAL: norm( x, 400 ); |
|||
PROC normm = ( REAL x )REAL: norm( x, 6400 ); |
|||
PROC normr = ( REAL x )REAL: norm( x, 2 * pi ); |
|||
PROC d2g = ( REAL x )REAL: normd( x ) * 10 / 9; |
|||
PROC d2m = ( REAL x )REAL: normd( x ) * 160 / 9; |
|||
PROC d2r = ( REAL x )REAL: normd( x ) * pi / 180; |
|||
PROC g2d = ( REAL x )REAL: normg( x ) * 9 / 10; |
|||
PROC g2m = ( REAL x )REAL: normg( x ) * 16; |
|||
PROC g2r = ( REAL x )REAL: normg( x ) * pi / 200; |
|||
PROC m2d = ( REAL x )REAL: normm( x ) * 9 / 160; |
|||
PROC m2g = ( REAL x )REAL: normm( x ) / 16; |
|||
PROC m2r = ( REAL x )REAL: normm( x ) * pi / 3200; |
|||
PROC r2d = ( REAL x )REAL: normr( x ) * 180 / pi; |
|||
PROC r2g = ( REAL x )REAL: normr( x ) * 200 / pi; |
|||
PROC r2m = ( REAL x )REAL: normr( x ) * 3200 / pi; |
|||
STRING underline = "----------------------------------------------------------------------------------"; |
|||
PROC printhd = ( STRING heading )VOID: |
|||
BEGIN |
|||
print( ( heading, newline ) ); |
|||
print( ( underline, newline ) ) |
|||
END # print heaading # ; |
|||
PROC f7d7 = ( REAL v )STRING: fixed( v, -15, 7 ); |
|||
PROC print values = ( PROC(REAL)REAL norm, f2a, f2b, f2c )VOID: |
|||
FOR i FROM LWB values TO UPB values DO |
|||
REAL v = values[ i ]; |
|||
print( ( f7d7( v ), " ", f7d7( norm( v ) ), " ", f7d7( f2a( v ) ), " " ) ); |
|||
print( ( f7d7( f2b( v ) ), " ", f7d7( f2c( v ) ), newline ) ) |
|||
OD # print values # ; |
|||
printhd( " Degrees Normalized Gradians Mils Radians" ); |
|||
print values( normd, d2g, d2m, d2r ); |
|||
print( ( newline ) ); |
|||
printhd( " Gradians Normalized Degrees Mils Radians" ); |
|||
print values( normg, g2d, g2m, g2r ); |
|||
print( ( newline ) ); |
|||
printhd( " Mils Normalized Degrees Gradians Radians" ); |
|||
print values( normm, m2d, m2g, m2r ); |
|||
print( ( newline ) ); |
|||
printhd( " Radians Normalized Degrees Gradians Mils" ); |
|||
print values( normr, r2d, r2g, r2m ); |
|||
print( ( newline ) ) |
|||
END |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
Degrees Normalized Gradians Mils Radians |
|||
---------------------------------------------------------------------------------- |
|||
-2.0000000 -2.0000000 -2.2222222 -35.5555556 -0.0349066 |
|||
-1.0000000 -1.0000000 -1.1111111 -17.7777778 -0.0174533 |
|||
0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 |
|||
1.0000000 1.0000000 1.1111111 17.7777778 0.0174533 |
|||
2.0000000 2.0000000 2.2222222 35.5555556 0.0349066 |
|||
6.2831853 6.2831853 6.9813170 111.7010720 0.1096623 |
|||
16.0000000 16.0000000 17.7777778 284.4444444 0.2792527 |
|||
57.2957795 57.2957795 63.6619772 1018.5916356 1.0000000 |
|||
359.0000000 359.0000000 398.8888889 6382.2222222 6.2657320 |
|||
399.0000000 39.0000000 43.3333333 693.3333333 0.6806784 |
|||
6399.0000000 279.0000000 310.0000000 4960.0000000 4.8694686 |
|||
1000000.0000000 280.0000000 311.1111111 4977.7777778 4.8869219 |
|||
Gradians Normalized Degrees Mils Radians |
|||
---------------------------------------------------------------------------------- |
|||
-2.0000000 -2.0000000 -1.8000000 -32.0000000 -0.0314159 |
|||
-1.0000000 -1.0000000 -0.9000000 -16.0000000 -0.0157080 |
|||
0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 |
|||
1.0000000 1.0000000 0.9000000 16.0000000 0.0157080 |
|||
2.0000000 2.0000000 1.8000000 32.0000000 0.0314159 |
|||
6.2831853 6.2831853 5.6548668 100.5309648 0.0986960 |
|||
16.0000000 16.0000000 14.4000000 256.0000000 0.2513274 |
|||
57.2957795 57.2957795 51.5662015 916.7324720 0.9000000 |
|||
359.0000000 359.0000000 323.1000000 5744.0000000 5.6391588 |
|||
399.0000000 399.0000000 359.1000000 6384.0000000 6.2674773 |
|||
6399.0000000 399.0000000 359.1000000 6384.0000000 6.2674773 |
|||
1000000.0000000 0.0000000 0.0000000 0.0000000 0.0000000 |
|||
Mils Normalized Degrees Gradians Radians |
|||
---------------------------------------------------------------------------------- |
|||
-2.0000000 -2.0000000 -0.1125000 -0.1250000 -0.0019635 |
|||
-1.0000000 -1.0000000 -0.0562500 -0.0625000 -0.0009817 |
|||
0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 |
|||
1.0000000 1.0000000 0.0562500 0.0625000 0.0009817 |
|||
2.0000000 2.0000000 0.1125000 0.1250000 0.0019635 |
|||
6.2831853 6.2831853 0.3534292 0.3926991 0.0061685 |
|||
16.0000000 16.0000000 0.9000000 1.0000000 0.0157080 |
|||
57.2957795 57.2957795 3.2228876 3.5809862 0.0562500 |
|||
359.0000000 359.0000000 20.1937500 22.4375000 0.3524474 |
|||
399.0000000 399.0000000 22.4437500 24.9375000 0.3917173 |
|||
6399.0000000 6399.0000000 359.9437500 399.9375000 6.2822036 |
|||
1000000.0000000 1600.0000000 90.0000000 100.0000000 1.5707963 |
|||
Radians Normalized Degrees Gradians Mils |
|||
---------------------------------------------------------------------------------- |
|||
-2.0000000 -2.0000000 -114.5915590 -127.3239545 -2037.1832716 |
-2.0000000 -2.0000000 -114.5915590 -127.3239545 -2037.1832716 |
||
-1.0000000 -1.0000000 -57.2957795 -63.6619772 -1018.5916358 |
-1.0000000 -1.0000000 -57.2957795 -63.6619772 -1018.5916358 |