119 lines
5.0 KiB
Plaintext
119 lines
5.0 KiB
Plaintext
This task is about the normalization and/or conversion of (geometric) angles using
|
|
some common scales.
|
|
|
|
|
|
The angular scales that will be used in this task are:
|
|
::* degree
|
|
::* gradian
|
|
::* mil
|
|
::* radian
|
|
|
|
|
|
|
|
;Definitions:
|
|
The angular scales used or referenced here:
|
|
::* '''turn''' is a full turn or 360 degrees, also shown as 360º
|
|
::* '''degree''' is <big>'''<sup>1</sup>/<sub>360</sub>'''</big> of a turn
|
|
::* '''gradian''' is <big>'''<sup>1</sup>/<sub>400</sub>'''</big> of a turn
|
|
::* '''mil''' is <big>'''<sup>1</sup>/<sub>6400</sub>'''</big> of a turn
|
|
::* '''radian''' is <big>'''<sup>1</sup>/<sub>2<big><big><math>\pi</math></big></big></sub></big>''' of a turn (or <big>'''<sup>0.5</sup>/<sub><big><big><math>\pi</math></big></big></sub>'''</big> of a turn)
|
|
|
|
|
|
Or, to put it another way, for a full circle:
|
|
::* there are '''360''' degrees
|
|
::* there are '''400''' gradians
|
|
::* there are '''6,400''' mils
|
|
::* there are '''2<big><big><math>\pi</math></big></big>''' radians (roughly equal to '''6.283<small>+</small>''')
|
|
|
|
|
|
A '''mil''' is approximately equal to a ''milliradian'' (which is <big>'''<sup>1</sup>/<sub>1000</sub>'''</big> of a radian).
|
|
|
|
There is another definition of a '''mil''' which
|
|
is '''<sup>1</sup>/<sub>1000</sub>''' of a radian ─── this
|
|
definition <u>won't</u> be used in this Rosetta Code task.
|
|
|
|
|
|
'''Turns''' are sometimes known or shown as:
|
|
:::* turn(s)
|
|
:::* 360 degrees
|
|
:::* unit circle
|
|
:::* a (full) circle
|
|
|
|
|
|
'''Degrees''' are sometimes known or shown as:
|
|
:::* degree(s)
|
|
:::* deg
|
|
:::* º (a symbol)
|
|
:::* ° (another symbol)
|
|
|
|
|
|
'''Gradians''' are sometimes known or shown as:
|
|
:::* gradian(s)
|
|
:::* grad(s)
|
|
:::* grade(s)
|
|
:::* gon(s)
|
|
:::* metric degree(s)
|
|
:::* (Note that '''centigrade''' was used for <sup>1</sup>/<sub>100</sub><sup>th</sup> of a grade, see the note below.)
|
|
|
|
|
|
'''Mils''' are sometimes known or shown as:
|
|
:::* mil(s)
|
|
:::* NATO mil(s)
|
|
|
|
|
|
'''Radians''' are sometimes known or shown as:
|
|
:::* radian(s)
|
|
:::* rad(s)
|
|
|
|
|
|
|
|
;Notes:
|
|
In continental Europe, the French term '''centigrade''' was used
|
|
for '''<sup>1</sup>/<sub>100</sub>''' of a grad (grade); this was
|
|
one reason for the adoption of the term '''Celsius''' to
|
|
replace '''centigrade''' as the name of a temperature scale.
|
|
|
|
Gradians were commonly used in civil engineering.
|
|
|
|
Mils were normally used for artillery (elevations of the gun barrel for ranging).
|
|
|
|
|
|
;Positive and negative angles:
|
|
Although the definition of the measurement of an angle doesn't support the
|
|
concept of a negative angle, it's frequently useful to impose a convention that
|
|
allows positive and negative angular values to represent orientations and/or rotations
|
|
in opposite directions relative to some reference. It is this reason that
|
|
negative angles will keep their sign and <u>not</u> be normalized to positive angles.
|
|
|
|
|
|
;Normalization:
|
|
Normalization (for this Rosetta Code task) will keep the same
|
|
sign, but it will reduce the magnitude to less than a full circle; in
|
|
other words, less than 360º.
|
|
|
|
Normalization <u>shouldn't</u> change '''-45º''' to '''315º''',
|
|
|
|
An angle of '''0º''', '''+0º''', '''0.000000''', or '''-0º''' should be
|
|
shown as '''0º'''.
|
|
|
|
|
|
;Task:
|
|
::* write a function (or equivalent) to do the normalization for each scale
|
|
:::::* Suggested names:
|
|
:::::* '''d2d''', '''g2g''', '''m2m''', and '''r2r'''
|
|
::* write a function (or equivalent) to convert one scale to another
|
|
:::::* Suggested names for comparison of different computer language function names:
|
|
:::::* '''d2g''', '''d2m''', and '''d2r''' for degrees
|
|
:::::* '''g2d''', '''g2m''', and '''g2r''' for gradians
|
|
:::::* '''m2d''', '''m2g''', and '''m2r''' for mils
|
|
:::::* '''r2d''', '''r2g''', and '''r2m''' for radians
|
|
::* normalize all angles used (except for the "original" or "base" angle)
|
|
::* show the angles in every scale and convert them to all other scales
|
|
::* show all output here on this page
|
|
|
|
|
|
For the (above) conversions, use these dozen numbers (in the order shown):
|
|
:* '''-2 -1 0 1 2 6.2831853 16 57.2957795 359 399 6399 1000000'''
|
|
<br><br>
|
|
|