.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Bot Coding
General Bot Coding See what a pain it is to get those little mechs shooting around

Reply
 
Thread Tools
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
Re: l33t h4x0r's way to do trig
Old
  (#2)
TruB
One Eyed Freak
 
TruB's Avatar
 
Status: Offline
Posts: 1,164
Join Date: Dec 2003
Location: local mall
Default Re: l33t h4x0r's way to do trig - 26-04-2004

good thing cos and sin is avaible anyway..
  
Reply With Quote
Re: l33t h4x0r's way to do trig
Old
  (#3)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: l33t h4x0r's way to do trig - 26-04-2004

this is just @$3.1415riningly nonunderstandable, Whistler... where did you get that from ? o_O



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Re: l33t h4x0r's way to do trig
Old
  (#4)
KickBot
Member
 
Status: Offline
Posts: 17
Join Date: Apr 2004
Default Re: l33t h4x0r's way to do trig - 26-04-2004

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.
  
Reply With Quote
Re: l33t h4x0r's way to do trig
Old
  (#5)
@$3.1415rin
Council Member, Author of JoeBOT
 
@$3.1415rin's Avatar
 
Status: Offline
Posts: 1,381
Join Date: Nov 2003
Location: Germany
Default Re: l33t h4x0r's way to do trig - 26-04-2004

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



Last edited by @$3.1415rin; 26-04-2004 at 17:18..
  
Reply With Quote
Re: l33t h4x0r's way to do trig
Old
  (#6)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Re: l33t h4x0r's way to do trig - 26-04-2004

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


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Re: l33t h4x0r's way to do trig
Old
  (#7)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: l33t h4x0r's way to do trig - 26-04-2004

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



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."

Last edited by Pierre-Marie Baty; 26-04-2004 at 19:22..
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com