Your own math function
module Math
RAD2DEG = 360.0/(2.0*PI) # Radians to degrees
RAD2GRAD = 400.0/(2.0*PI) # Radians to grads
end
def sin_d(theta)
Math.sin(theta/Math::RAD2DEG)
end
def sin_g(theta)
Math.sin(theta/Math::RAD2GRAD)
end
def atan2_d(y,x)
Math.atan2(y,x)/Math::RAD2DEG
end
def atan2_g(y,x)
Math.atan2(y,x)/Math::RAD2GRAD
end
def arcsin(x)
Math.atan2(x,Math.sqrt(1.0-x*x))
end
def arccos(x)
Math.atan2(Math.sqrt(1.0-x*x),x)
end
def arctan(x)
Math.atan2(x,1.0)
end
def sinh(x)
(Math.exp(x)-Math.exp(-x))/2.0
end
def cosh(x)
(Math.exp(x)+Math.exp(-x))/2.0
end
def tanh(x)
sinh(x)/cosh(x)
end
def asinh(x)
Math.log(x + Math.sqrt(1.0+x**2))
end
def acosh(x)
2.0 *Math.log(Math.sqrt((x+1.0)/2.0)+Math.sqrt((x-1)/2.0))
end
def atanh(x)
(Math.log(1.0+x) - Math.log(1.0-x))/2.0
end
Related examples in the same category