17
This is a fairly simple question. According to this random website I found — Web Archive, a reference angle is the acute angle formed by the terminal side of the given angle and the x-axis.
You have to write a program to find these.
I don't remember anything from algebra 2, what does this mean?
Angles are usually given in standard form, which is measured by placing one side of the angle and measuring to the other side, counterclockwise, like so:
This will be your input. Your output will be the reference angle of this. You can think of this as basically the smallest distance from the terminal side to the x-axis. Except it's an angle, not a distance. Here are some examples:
Clarifications
- All the defaults on inputs and submissions.
- Angles is in degrees.
- Negative angles, non-integer angles, and angles > 360 deg are allowed.
- Output in form
60 deg
. - This is code-golf, so shortest code in bytes wins!
Test Cases
70 -> 70 deg
135 -> 45 deg
210 -> 30 deg
-60 -> 60 deg
91 -> 89 deg
610 -> 70 deg
-1000 -> 80 deg
1What do we do on input of 90? – lirtosiast – 2015-07-25T05:51:37.747
2@ThomasKwa it would be 90 from either direction. – Maltysen – 2015-07-25T05:53:21.217
1A short solution is
abs(arcsin(sin(input)))+" deg"
, though I don't know which language would win (it would need to support degrees and string operations). – lirtosiast – 2015-07-25T06:02:40.943Is the input always an integer? – lirtosiast – 2015-07-25T06:08:26.847
@ThomasKwa good point, no. – Maltysen – 2015-07-25T06:12:07.527
6Since non-integer angles are allowed, you should include one in the test cases. – Dennis – 2015-07-25T13:32:24.070