Search code examples
pythonnumpytrigonometrygon

Python math module grad


I am trying to use the basic sin, cos, arctan, etc function from numpy, but I want to use gradians. I have search the doc without success, and search for other python modules without luck. Any suggestion on a python module i could use?

Or a function that will work. I have tried different methods to convert grad to rad and back to grad again, but no-one is working.


Solution

  • This one should be fine !

    def gradFromRad(rad):
        return 200*rad/math.pi
    def radFromGrad(grad):
        return math.pi*grad/200