def get_instance(geo_coord=None, earth_coord=None, planet=None, time=None): ''' Returns a RaDec instance given either geocentric coordinates or heliocentric coordinates with a planet and the time. ''' if geo_coord == None and earth_coord == None: raise Exception("must provide geo_coords or helio_coords") if geo_coord != None: raRad = math.atan2(geo_coord.y, geo_coord.x) if (raRad < 0): raRad += math.pi * 2.0 decRad = math.atan2(geo_coord.z, math.sqrt(geo_coord.x * geo_coord.x + \ geo_coord.y * geo_coord.y)) return RaDec(radians_to_degrees(raRad), radians_to_degrees(decRad)) else: if planet.id == planet_enum.MOON: return planet.calculate_lunar_geocentric_location(time) coords = None if planet.id == planet_enum.SUN: # Invert the view, since we want the Sun in earth coordinates, not the Earth in sun # coordinates. coords = HeliocentricCoordinates(earth_coord.radius, earth_coord.x * -1.0, earth_coord.y * -1.0, earth_coord.z * -1.0) else: coords = hc_get_instance(None, planet, time) coords.subtract(earth_coord) equ = coords.calculate_equitorial_coords() return calculate_ra_dec_dist(equ)
def get_instance(geo_coord=None, earth_coord=None, planet=None, time=None): ''' Returns a RaDec instance given either geocentric coordinates or heliocentric coordinates with a planet and the time. ''' if geo_coord == None and earth_coord == None: raise Exception("must provide geo_coords or helio_coords") if geo_coord != None: raRad = math.atan2(geo_coord.y, geo_coord.x) if (raRad < 0): raRad += math.pi * 2.0 decRad = math.atan2(geo_coord.z, math.sqrt(geo_coord.x * geo_coord.x + \ geo_coord.y * geo_coord.y)); return RaDec(radians_to_degrees(raRad), radians_to_degrees(decRad)) else: if planet.id == planet_enum.MOON: return planet.calculate_lunar_geocentric_location(time) coords = None if planet.id == planet_enum.SUN: # Invert the view, since we want the Sun in earth coordinates, not the Earth in sun # coordinates. coords = HeliocentricCoordinates(earth_coord.radius, earth_coord.x * -1.0, earth_coord.y * -1.0, earth_coord.z * -1.0) else: coords = hc_get_instance(None, planet, time) coords.subtract(earth_coord) equ = coords.calculate_equitorial_coords() return calculate_ra_dec_dist(equ)
def __init__(self, model, controller_group, shared_prefs, screen_height): ''' Constructor ''' self.model = model self.control_group = controller_group self.shared_prefs = shared_prefs self.size_times_rads_to_degs = radians_to_degrees(screen_height) self.allow_rotation = shared_prefs.ALLOW_ROTATION
def distance_from(self, lat_long): other_point = GC.get_instance(lat_long.longitude, lat_long.latitude) this_point = GC.get_instance(self.longitude, self.latitude) cos_Theta = cosine_similarity(this_point, other_point) return radians_to_degrees(math.acos(cos_Theta))