|
Post by andrian on Aug 1, 2008 14:02:18 GMT -5
These inverse math functions would be really useful. I know it wouldn't be that hard to add them (they're practically built into C++).
It is rather difficult to live without them.
|
|
|
Post by chris857 on Aug 22, 2010 21:07:25 GMT -5
They can be found, rather interestingly, in the JAPI plugin.
|
|
|
Post by DJLinux on Aug 23, 2010 14:21:20 GMT -5
you can try to build build your own versions sorry if it is not working in all cases i'm not an math guru :-) Joshy ' simple form Function ArcSin#(X#) return Atn(X# / Sqr(-X# * X# + 1)) End Function
Function ArcCos#(X#) return Atn(-X# / Sqr(-X# * X# + 1)) + 2 * Atn(1) End Function
' more save Function ACOS#(x#) If x# = 0 Then return Atn(1) * 2 ElseIf x# = -1 Then return Atn(1) * 4 ElseIf x# = 1 Then return 0 Else return Atn(-x# / Sqr(-x# * x# + 1)) + Atn(1) * 2 End If End Function
Function ASIN#(x#) If x# = 0 Then return 0 ElseIf x# = -1 Then return 0 ElseIf x# = 1 Then return Atn(1) * 2 Else return Atn(x# / Sqr(-x# * x# + 1)) End If End Function
dim x# for x# = 0 to 1 step 0.1 printr ArcSin#(x#) + "," + ArcCos#(x#) printr ASin#(x#) + "," + ACos#(x#) next
|
|
|
Post by DJLinux on Aug 23, 2010 14:36:00 GMT -5
here are for radians or degrees const DEG_TO_RAD# = M_PI/180.0 const RAD_TO_DEG# = 180.0/M_PI
' simple form ' x# in rad Function ArcSin#(X#) return Atn(X# / Sqr(-X# * X# + 1)) End Function Function ArcCos#(X#) return Atn(-X# / Sqr(-X# * X# + 1)) + 2 * Atn(1) End Function ' x# in deg Function ArcSinD#(X#) x#=x#*DEG_TO_RAD# return Atn(X# / Sqr(-X# * X# + 1)) End Function Function ArcCosD#(X#) x#=x#*DEG_TO_RAD# return Atn(-X# / Sqr(-X# * X# + 1)) + 2 * Atn(1) End Function
' more save ' x# in rad Function ACOS#(x#) If x# = 0 Then return Atn(1) * 2 ElseIf x# = -1 Then return Atn(1) * 4 ElseIf x# = 1 Then return 0 Else return Atn(-x# / Sqr(-x# * x# + 1)) + Atn(1) * 2 End If End Function Function ASIN#(x#) If x# = 0 Then return 0 ElseIf x# = -1 Then return 0 ElseIf x# = 1 Then return Atn(1) * 2 Else return Atn(x# / Sqr(-x# * x# + 1)) End If End Function ' x# in deg Function ACOSD#(x#) x#=x#*DEG_TO_RAD# If x# = 0 Then return Atn(1) * 2 ElseIf x# = -1 Then return Atn(1) * 4 ElseIf x# = 1 Then return 0 Else return Atn(-x# / Sqr(-x# * x# + 1)) + Atn(1) * 2 End If End Function
Function ASIND#(x#) x#=x#*DEG_TO_RAD# If x# = 0 Then return 0 ElseIf x# = -1 Then return 0 ElseIf x# = 1 Then return Atn(1) * 2 Else return Atn(x# / Sqr(-x# * x# + 1)) End If End Function
|
|