Hi,
>Does anybody know how to do inverse sin, tan, cosin in Director??
on getInvSin(x)
if x <= 1.0 and x >= -1.0 then
b = sqrt(1.0 - x * x)
if b <> 0.0 then
return atan(x / b)
else
return 0.5 * pi() * ((x = 1.0) - (x = -1.0))
end if
else
alert "x out of range"
return -2
end if
end
Only values in the range +/- 1.0 must be passed to the
formal parameter x, otherwise the handler issues an alert
and returns -2 or any integer value of your choice out of
the interval +/- pi()/2, that's out of the normal range of
return values. But imo the best would be eliminating the
test on x: it consumes time and the calling routine should
be always aware of what it's passing to getInvSin() before
to call it. This is a general rule, for me.
Also, calculating 0.5 * pi() all times should be avoided.
So:
global _pi_2
_pi_2 = 0.5 * pi() -- somewhere in a movie script
on getInvSin(x)
b = sqrt(1.0 - x * x)
if b <> 0.0 then
return atan(x / b)
else
return _pi_2 * ((x = 1.0) - (x = -1.0))
end if
end
This is faster, but unfortunately it never came in mind
how to eliminate the square root - maybe a Taylor's (or Mc Laurin's,
in some circumstances) series truncted at the first term?
Hope this help.
Franco
IFC Programming Consultant
http://www.chnexus.com/main.htm
Private mailto:[EMAIL PROTECTED]
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi To post messages to the list,
email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo. Thanks!]