.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Bot Coding (http://forums.bots-united.com/forumdisplay.php?f=24)
-   -   l33t h4x0r's way to do trig (http://forums.bots-united.com/showthread.php?t=1498)

Whistler 26-04-2004 11:45

l33t h4x0r's way to do trig
 
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. :)

TruB 26-04-2004 12:45

Re: l33t h4x0r's way to do trig
 
good thing cos and sin is avaible anyway..

Pierre-Marie Baty 26-04-2004 14:51

Re: l33t h4x0r's way to do trig
 
this is just @$3.1415riningly nonunderstandable, Whistler... where did you get that from ? o_O

KickBot 26-04-2004 15:50

Re: l33t h4x0r's way to do trig
 
Nice hax. "fsincos" is some kind of asm/3dnow now macro or something? ???:(
BTW cos and sin operates on *double*, cosf and sinf operates on *float* I use this only since I assume they are faster than their double brothers.

@$3.1415rin 26-04-2004 16:14

Re: l33t h4x0r's way to do trig
 
Quote:

Originally Posted by Pierre-Marie Baty
this is just @$3.1415riningly nonunderstandable, Whistler... where did you get that from ? o_O

well, why not understandable ? plain asm, nothing more, or did I miss something ...

whistler, for asm stuff on gcc you can check __asm__ :-) I had this problem too, with my high precision timer

Quote:

Originally Posted by KickBot
BTW cos and sin operates on *double*, cosf and sinf operates on *float* I use this only since I assume they are faster than their double brothers.

on current cpu's this shouldnt make much a difference as long as you don't do millions of float operations and hit the mem transfer limit. internally they use 80bit flpts, anyway, I think

stefanhendriks 26-04-2004 18:00

Re: l33t h4x0r's way to do trig
 
very l33t there indeed. Now we can run millions of times sin and cos and do some cool stuff with it. Dunno what yet though :)

Pierre-Marie Baty 26-04-2004 18:18

Re: l33t h4x0r's way to do trig
 
That's what I meant. Only you can understand it :)

For myself I have no clue what "fsincos" does and what's left in the registers after this call.

*edit*
lmao @ Stefan, good one dude :D


All times are GMT +2. The time now is 07:10.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.