print ("This program will calculate heliocentric distance.")
import math
# Formula for calculating the heliocentric distance:
# HelioCentricDistance = SemiMajorAxis * (1-(EccentricityVector * cos(EccentricAnomalyDegrees)))
###########################################
# 1 function: solve for the heliocentric distance
# math.cos(x in radians) - returns cosine of "x in radians"
# Function to solve for helicentric distance
# Enter the semi-major axis, eccentricity vector, and eccentric anomaly
# HelioCentricDistance = SemiMajorAxis * (1-(EccentricityVector * cos(EccentricAnomalyDegrees)))
def SolveForHeliocentricDistance():
print ("Solving for the heliocentric distance.")
# math.cos(x in radians) - returns cosine of "x in radians"
# Enter the semi-major axis, eccentricity vector, and eccentric anomaly
SemiMajorAxis = float(input("Enter the semi-major axis in meters: ") )
EccentricityVector = float(input("Enter the eccentricity vector (dimensionless): ") )
EccentricityAnomaly = float(input("Enter the eccentricity anomaly in degrees: ") )
# Now convert degrees to radians so that we can use the math.cos() function
# Use math.radians() to convert degrees to radians
EccentricityAnomalyInRadians = math.radians(EccentricityAnomaly)
print(EccentricityAnomaly, "degrees in radians is: ", EccentricityAnomalyInRadians)
# Now find cosine
CosineOfEccentricityAnomaly = math.cos(EccentricityAnomalyInRadians)
print("The cosine of ", EccentricityAnomalyInRadians, "is: ", CosineOfEccentricityAnomaly)
# Multiply cosine by eccentricity vector
VectorTimesCosine = (EccentricityVector*CosineOfEccentricityAnomaly)
# Subtract from one
SubractFromOne = (1 - VectorTimesCosine)
# Multiply by semi-major axis
HeliocentricDistance = (SemiMajorAxis * SubractFromOne)
print("The helicentric distance is: ", HeliocentricDistance)
ContinueCalculations = "y"
# Check to see if the user wants to continue to calculate the helicentric distance
while (ContinueCalculations=="y"):
SolveForHeliocentricDistance()
ContinueCalculations = input("Would like to do another calculation for the helicentric distance? (y/n): ")
print("==================================")
print ("Thank you to www.fxsolver.com for assistance with this formula.")