Bots and Simulations > DNA - General
sin and cos approximation
abyaly:
Where is this program available?
PurpleYouko:
It's an attachment to This post
It runs in Microsoft Excel sp obviously you need to have this installed on your PC.
Oh and one more thing. It isn't quite complete and doesn't include specific code for all the commands yet. Chances are it won't be able to handle Welworion's bot yet as he uses some of the more recent math functions.
Welwordion:
--- Code: ---*.refxpos *.refypos angle -1 mult *.aim add
'make sure the angle is within the right range
1256 add 1256 mod
'forgot which one was sin and which cos, the ceil and floor are used for the purpose of improving precision, as its easier to do values in a certain area
' and since sin and cos is a symetric function we used this to our advantage I also used only sine and just changed the input value by 314 '90 degree
dup dup dup dup dup 314 ceil swapint
314 floor 942 ceil 314 sub sub swapint
942 floor 942 sub add 2 div
dup 0 swapint 3 pow 600 div 100 div sub add
2 div *.veldx sub .dx store
628 ceil -1 mult 314 add swapint
628 floor 628 sub add 2 div
dup 0 swapint 3 pow 600 div 100 div sub add
2 div *.velup sub .up store
--- End code ---
Know its an really old post of mine but I realized I never put the newest version of the code here.
Numsgil:
Looks much leaner :)
Welwordion:
yep made some tricky moves as I had explained back in this post,
http://forum.darwinbots.com/index.php/topic,3001.msg1378841.html
actually I think its the last version I posted in the following post back in 2007
http://forum.darwinbots.com/index.php/topic,2408.msg1374432.html
but when I saw the post listed below, which also tackle the sin, cos problem
http://forum.darwinbots.com/index.php/topic,3078.msg1379970.html
http://forum.darwinbots.com/index.php/topic,3367.msg1382216.html
I thought either my solution was forgotten or people did not like it for some reason
so I thought might be helpful to bring it back to memory for those that face the same problem
or give people the chance to tell me of a more elegant way.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version