13
4
Given two points A
and B
, find the angle from line AO
to line BO
about point O
where O
is the origin ((0,0)
). Additionally, the angle may be positive or negative depending on the positions of the points (see examples). Input will be points A
and B
, and may be given in any convenient form. Output will be the angle in degrees (but it is positive if AO
is rotated counter-clockwise about the origin to get BO
and negative if it is rotated clockwise). If the angle is 180 degrees you may return a negative or positive output. Similarly, the angle can be the positive or negative version of the same angle (90 deg
is equal to -270 deg
). Examples:
Input:
A(5,5) B(5,-5)
Output:-90
(AO
is rotated-90
degrees to getBO
).Input:
A(5,-5) B(5,5)
Output:90
(AO
is rotated90
degrees to getBO
).
This is code-golf, so shortest code in bytes wins!
Your examples only have multiples of 90 degs in them. Is this true for our programs as well, or do they have to deal with arbitrary angles? – Maltysen – 2015-10-26T04:25:44.140
Arbitrary angles as well. – Alien G – 2015-10-26T04:27:01.747
11How much precision is required? – Reto Koradi – 2015-10-26T04:35:35.763
2Can we take input as two complex numbers? – lirtosiast – 2015-10-26T04:51:03.547
Can we output as a one-element list containing the angle? – lirtosiast – 2015-10-26T05:04:24.333
5What should the output be if one point is
(0,0)
? – lirtosiast – 2015-10-26T05:28:01.4501@ThomasKwa I don't know about the OP, but I treated it as only integer/decimal number input, and the input would never have a (0,0) point. – GamrCorps – 2015-10-26T13:38:52.607
2Hint: The angle between
AO
andBO
would usually be called angleAOB
. – ETHproductions – 2015-10-26T15:56:13.550