Map N,S,E,W Angle system System to 360° Angle System

Viewed 128

I have a coordinate system where North has the angle value 1. East +0.707 and West -0.707. South has the angle 0. It's very annoying to calculate angle deltas in this angle system. Is there a nice way to convert it to a standard 0 to 360 degree coordinate system? Python solution preferred but I'm more interested in the operations instead of ready to use implementation.

2 Answers

0.707 is the cosine of 45°. So your current system shows you the cosine of your angle divided by 2, as I would expect a 90° value for West. If you apply the transformation 180/pi * arccos(x) * 2, where x is your current value, you will get a 0° to 360° value, where 0° or 360° will be North, and 180° will be South.

The 180/pi factor is there to convert from the radians output of the arccos function.

That angle system is very weird. It seems like your "angle" is calculated as sin(radians(d/2)) where d is actual angle in degrees (with south being 0° and east 90°). You can invert this:

>>> from math import *
>>> ewns = [0.707, -0.707, 1.0, 0.0]
>>> [degrees(asin(x) * 2) for x in ewns]
[89.98269667432403, -89.98269667432403, 180.0, 0.0]

Optionally round and add % 360 to get 0..360 instead of -180..180:

>>> [round(degrees(asin(x) * 2)) % 360 for x in ewns]
[90, 270, 180, 0]
Related