class CmO:
"""
This class will contain specific code that is required to run a C-O calculation
This includes range and bearing calc
"""
def __init__(self, *args, **kwargs):
"""
:param a_e: initial easting
:param a_n: initial northing
"""
self.a_e = kwargs.get('a_e', None)
self.a_n = kwargs.get('a_n', None)
def complex_randb(self, r, b):
"""
An equation that using imaginary numbers to calculate the coordinates of a new
point from a range and bearing of an old point
:param r: range from original coordinate to new coordinate
:param b: bearing from original coordinate to new coordinate
"""
# -b is required as geodetic bearings are opposite to mathematical bearings
t = complex(cos(radians(-b)), sin(radians(-b))) * complex(0, r)
delta_easting = t.real
delta_northing = t.imag
if self.a_e and self.a_n is not False:
new_easting = self.a_e + delta_easting
new_northing = self.a_n + delta_northing
return new_easting, new_northing
else:
return delta_easting, delta_northing