View Single Post
l33t h4x0r's way to do trig
Old
  (#1)
Whistler
Summoner
 
Whistler's Avatar
 
Status: Offline
Posts: 1,499
Join Date: Feb 2004
Location: Mist Village
Default l33t h4x0r's way to do trig - 26-04-2004

Code:
 void inline ASMSinCos( float rad, float *sin, float *cos )
 {
 #ifdef _MSC_VER // This routine seems to be M$ specific...
    _asm
    {
 	  fld DWORD PTR[rad]
 	  fsincos
 	  mov edx, DWORD PTR[cos]
 	  mov eax, DWORD PTR[sin]
 	  fstp DWORD PTR[edx]
 	  fstp DWORD PTR[eax]
    }
 #else
    *sin = sin(rad);
    *cos = cos(rad);
 #endif
 }
This one is tested thoroughly without problem, anyway you might need VC Processor Pack to use this

This is much faster than just using sin() and cos(). Maybe it's useful for l33t math beasts who uses scary math routine everywhere in code.
  
Reply With Quote