Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: Perl oddities

by talexb (Canon)
on Mar 01, 2005 at 19:01 UTC ( #435575=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Perl oddities
in thread Perl oddities

    sin, cos, and atan2 are "primitive" functions.

Well, once you have a routine for sin, then cos is the same thing, but pi/2 sooner. And I'm fairly sure that's the way it's implemented in the libraries.

Using atan2 to do an inverse sin or cos is a bit of a walk in the park, but essentially I guess you have to find the 'Y' value once you have the 'X', then submit both to atan2, and that will give you the angle you're looking for.

That's a nice brain exercise right after lunch.

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds


Comment on Re^3: Perl oddities
Select or Download Code
Re^4: Perl oddities
by theorbtwo (Prior) on Mar 02, 2005 at 11:59 UTC

    I suspect on most CPUs, it just uses the sin and cos opcodes of the native CPU. Implementing sin in terms of cos (or vice-versa) is just asking for problems, like the well-known results being a little off, since pi/2 cannot be exactly represented as a float (or as anything else in finite RAM).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://435575]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (13)
As of 2014-12-18 13:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (51 votes), past polls