Search code examples
pythonmathdegreesradians

How do I write these equations in pure Python?


Given these example equations with all but the word degrees in broken python:

L = 280.460 degrees + 0.9856474 degrees * n

and

lamtha = L + 1.915 degrees * math.sin(g) + 0.020 degrees * math.sin(2*g)

How can I can I write these in functional python to get the correct values for L and lamtha?


Solution

  • math.sin requires that you pass radians to it when you call it. If you pass your input as degrees, you will not get the correct result - convert to radians before you call math.sin.

    The return value of math.sin won't be in degrees or radians - it's just a ratio, so there's nothing to convert there.