Re: Trigonometry
Re: Trigonometry
- Subject: Re: Trigonometry
- From: "Mark J. Reed" <email@hidden>
- Date: Wed, 13 Dec 2006 21:32:06 -0500
That's just the usual rounding error you get with floating point math.
Special-casing it with if is not the thing to do. You should (1)
force the argument within a single period of the function's domain (so
never try to take a trig function of a number less than 0 or greater
than 2π) and then - and this has much wider applicability than trig -
treat any number whose magnitude is below a certain "epsilon" value as
zero.
On 12/13/06, Royalguard11 <email@hidden> wrote:
I'm not really sure if this is the right list to send this to, but the
applescript essential subroutine (under Math routines:
http://www.apple.com/applescript/guidebook/sbrt/pgs/sbrt.02.htm)
contains an error. Specifically the trig ones. The problem is when
trying to get the Sine of 180, or the Cosine of 90 or 270, which
should all come out as 0. The script will instead return a number that
is very small (usually something close to 4.26446036797127E-17). I
have already corrected my versions of the script (using if commands
after getting the number between 0-360) that check for those numbers
and return 0, but I was hoping that Apple would make those corrections
for the future.
For reference, the specific if used:
if x is equal to 180 then
return 0
else
--convert from degrees to radians
and
if x is equal to 90 then
return 0
else if x is equal to 270 then
return 0
else
--convert from degrees to radians
Thank you!
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/mailman//archives/applescript-users
This email sent to email@hidden
--
Mark J. Reed <email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/mailman//archives/applescript-users
This email sent to email@hidden
References: | |
| >Trigonometry (From: Royalguard11 <email@hidden>) |