online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
import math def distance_to_sun(latitude, longitude, sun_radius_degrees=0, sun_angle_degrees=0, sun_height_km=5000): """ Calculate the distance from a point on the polar plane to the sun hovering above the plane. Parameters: latitude (float): Latitude of the point in the polar coordinate system (in degrees, +90 at origin). longitude (float): Longitude in degrees of the point in the polar coordinate system. sun_radius_degrees (float): Radius of the sun's position in the polar coordinate system (in degrees, +90 at origin). sun_angle_degrees (float): Angle in degrees of the sun's position in the polar coordinate system. sun_height_km (float): Height above the plane in kilometers (default is 5000 km). Returns: float: Distance from the point on the polar plane to the sun in kilometers. """ # Convert radius degrees to km def radius_degrees_to_km(radius_degrees): if radius_degrees >= 0: return 10000 - (radius_degrees / 90) * 10000 else: return 10000 + (abs(radius_degrees) / 90) * 10000 latitude_km = radius_degrees_to_km(latitude) sun_radius_km = radius_degrees_to_km(sun_radius_degrees) # Convert polar coordinates to Cartesian coordinates longitude_radians = math.radians(longitude) point_x = latitude_km * math.cos(longitude_radians) point_y = latitude_km * math.sin(longitude_radians) point_z = 0 # All points on the plane have z = 0 # Convert sun polar coordinates to Cartesian coordinates sun_angle_radians = math.radians(sun_angle_degrees) sun_x = sun_radius_km * math.cos(sun_angle_radians) sun_y = sun_radius_km * math.sin(sun_angle_radians) sun_z = sun_height_km # Calculate the distance between the point and the sun distance = math.sqrt((point_x - sun_x)**2 + (point_y - sun_y)**2 + (point_z - sun_z)**2) return distance # Example Usage sun_latitude_degrees = -22.9 # sun's latitude in degrees sun_longitude_degrees = -160.90 # sun's longitude in degrees sun_height_km = 5812.8426 # Height above the plane in km observer_latitude = -53.16 # Latitude of the observer point in degrees observer_longitude = -70.90 # Longitude of the observer point in degrees distance = distance_to_sun(observer_latitude, observer_longitude, sun_latitude_degrees, sun_longitude_degrees, sun_height_km) print(f"Distance from the point on the polar plane to the sun: {distance:.2f} km")

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue