Author Topic: How can you approximate sin-1?  (Read 7604 times)

Offline MysticalDumpling

  • Bot Destroyer
  • ***
  • Posts: 205
  • Kurwa chuj!
    • View Profile
How can you approximate sin-1?
« on: May 01, 2014, 03:52:04 PM »
Alas, sin-1 does not seem to be a valid operator according to the wiki. Does anyone know how to in DB?
To być albo nie być, oto jest ze pytanie

Offline MysticalDumpling

  • Bot Destroyer
  • ***
  • Posts: 205
  • Kurwa chuj!
    • View Profile
Re: How can you approximate sin-1?
« Reply #1 on: May 01, 2014, 04:21:14 PM »
Well, after a long time trawling through calculus functions and really, really technical documents, 2 broken pencils and several smudged sheets of looseleaf, I then discovered on Khan Academy than arcsin(x) = x + (x^3)/6. Then, I wasted even more looseleaf getting a "proper" DB function down.  I used previously wrangled trig equations to fid a pair of variables- the distance of the end target (c) and the angle needed to turn (capital b ).

c:
Code: [Select]
*.refxpos *.refypos dist sqr *.refvelscalr sqr add 2 *.refxpos *.refypos dist mult *.refvelscalr mult sub *.refaim cos

B
Now, I used c for short for the eq. above
Code: [Select]
*.refaim sin *.refvelscalar mult c div *.refaim sin *.refvelscalar mult c div 3 pow 6 div add
Full B:
Code: [Select]
*.refaim sin *.refvelscalar mult ]*.refxpos *.refypos dist sqr *.refvelscalr sqr add 2 *.refxpos *.refypos dist mult *.refvelscalr mult sub *.refaim cos div *.refaim sin *.refvelscalar mult *.refxpos *.refypos dist sqr *.refvelscalr sqr add 2 *.refxpos *.refypos dist mult *.refvelscalr mult sub *.refaim cos div 3 pow 6 div add
Now, I need to use my lengthy shot-dist calculating gene, a as-of-yet unknown shot velocity and a factor to account for maximum shot distance based on bot size, stick it together for an excessively long functio that most likely will have more bugs than a beehive.
« Last Edit: May 01, 2014, 05:04:15 PM by MysticalDumpling »
To być albo nie być, oto jest ze pytanie

Offline MysticalDumpling

  • Bot Destroyer
  • ***
  • Posts: 205
  • Kurwa chuj!
    • View Profile
Re: How can you approximate sin-1?
« Reply #2 on: May 01, 2014, 04:22:14 PM »
Then again, this was fun in a masochistic way  :happy:
To być albo nie być, oto jest ze pytanie

Offline MysticalDumpling

  • Bot Destroyer
  • ***
  • Posts: 205
  • Kurwa chuj!
    • View Profile
Re: How can you approximate sin-1?
« Reply #3 on: May 01, 2014, 04:44:45 PM »
[bump]
Now, I am working on trying to find shot-distance-based-on-bot-size-and-logx snippet.
This means trawling through VB. I know very little about VB, except it's fundamental basics. Woohoo.
To być albo nie być, oto jest ze pytanie

Offline MysticalDumpling

  • Bot Destroyer
  • ***
  • Posts: 205
  • Kurwa chuj!
    • View Profile
Re: How can you approximate sin-1?
« Reply #4 on: May 01, 2014, 04:50:04 PM »
Found this snippet
If rob(n).vbody > 10 Then
    Shots(a).nrg = Log(Abs(rob(n).vbody)) * 60 * rngmultiplier
    Dim temp As Long
    temp = (Shots(a).nrg + 40 + 1) \ 40 'divides and rounds up
    Shots(a).Range = temp
So, base shot range is the log of body, timess 60, times "nrgmultiplier", which I assume is .shootval


Also, it seems that shot velocity is 40

Now, to figger out a cohesive code line

If this works, it will be so badass....
« Last Edit: May 01, 2014, 04:59:37 PM by MysticalDumpling »
To być albo nie być, oto jest ze pytanie

Offline MysticalDumpling

  • Bot Destroyer
  • ***
  • Posts: 205
  • Kurwa chuj!
    • View Profile
Re: How can you approximate sin-1?
« Reply #5 on: May 01, 2014, 05:47:50 PM »
I got a seemingly very effective calculator for shootval for a seen distance:
Code: [Select]
*.body 2 logx 60 mult *.refxpos *.refypos dist sqr *.refvelscalar sqr add 2 *.refxpos *.refypos dist mult *.refvelscalar mult sub *.refaim cos sub abs 2 logx -1 mult .shootval store
When I tried to use one to predict shootangle, it is 90deg. off to the right. It goes:
Code: [Select]
*.refaim sin *.refvelscalar mult *.refxpos *.refypos dist sqr *.refvelscalar sqr add 2 *.refxpos *.refypos dist mult *.refvelscalar mult sub *.refaim cos div *.refaim sin *.refvelscalar mult *.refxpos *.refypos dist sqr *.refvelscalar sqr add 2 *.refxpos *.refypos dist mult *.refvelscalar mult sub *.refaim cos div 3 pow 6 div add *.aim sub .aimshoot store
Neither of these have shot velocity factored in.
To być albo nie być, oto jest ze pytanie

Offline MysticalDumpling

  • Bot Destroyer
  • ***
  • Posts: 205
  • Kurwa chuj!
    • View Profile
Re: How can you approximate sin-1?
« Reply #6 on: May 01, 2014, 05:56:45 PM »
Alas, pre-emptive aiming and shooting eludes me. Some of my notes in a txt file might help someone open up this vault of secrets

updated .txt
« Last Edit: May 01, 2014, 07:02:32 PM by MysticalDumpling »
To być albo nie być, oto jest ze pytanie

Offline MysticalDumpling

  • Bot Destroyer
  • ***
  • Posts: 205
  • Kurwa chuj!
    • View Profile
Re: How can you approximate sin-1?
« Reply #7 on: May 01, 2014, 07:05:16 PM »
I now have the "working" base for the pre-emtive aim:
Code: [Select]
start
-40 *.eye9 sgn mult -30 *.eye8 sgn mult add -20 *.eye7 sgn mult add -10 *.eye6 sgn mult add 10 *.eye4 sgn mult add 20 *.eye3 sgn mult add 30 *.eye2 sgn mult add 40 *.eye1 sgn mult add .aimsx store
*.refaim sin *.refvelscalar mult *.refxpos *.refypos dist sqr *.refvelscalar sqr add 2 *.refxpos *.refypos dist mult *.refvelscalar mult sub *.refaim cos div *.refaim sin *.refvelscalar mult *.refxpos *.refypos dist sqr *.refvelscalar sqr add 2 *.refxpos *.refypos dist mult *.refvelscalar mult sub *.refaim cos div 3 pow 6 div add
.aimsx store
stop


However (as noted in the txt), there are some issues:
Quote
'The aiming kinda works- it shoots ahead of the bot. However, depending on how "late" in the cycle (?)
'or something like that, it does not hit. Not taking into account shot velocity causes problems as well.
'Another problem is that it overturns with large distances.

This might mean there is some problem in the math. Helpings?
To być albo nie być, oto jest ze pytanie

Offline MysticalDumpling

  • Bot Destroyer
  • ***
  • Posts: 205
  • Kurwa chuj!
    • View Profile
Re: How can you approximate sin-1?
« Reply #8 on: May 01, 2014, 07:21:20 PM »
I just realized I was spamming the thread. Sorry  :wub:

Anyway, I think I realized my prob.- I used *.refaim, which is absolute aim. Instead, I should find the dir, convert it to deg (if is that necissary?), based on my bot's frame of reference.

I added *.aim sub to the end of every *.refaim. Now, it works a little better. However, sometimes it works, then it "randomly" rotates WAAAAY too far. Well, I'm getting somewhere...  :dry:
« Last Edit: May 01, 2014, 07:32:05 PM by MysticalDumpling »
To być albo nie być, oto jest ze pytanie

Offline Shadowgod2

  • Bot Destroyer
  • ***
  • Posts: 387
    • View Profile
Re: How can you approximate sin-1?
« Reply #9 on: May 01, 2014, 11:39:50 PM »
i can't help but notice that the equation doesn't factor in the vel of any bot as far as i can tell. this could help.

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Re: How can you approximate sin-1?
« Reply #10 on: May 02, 2014, 11:09:43 AM »
Code: [Select]
cond
start
*.xpos 33 cos add *.ypos 33 sin sub angle debugint
stop
end

PwaPwaPwaPwaaaaown  :P

edit:

Code: [Select]
Private Sub Form_Load()
Dim ang As Double
ang = 1.1
'MsgBox Sin(ang) & " " & Cos(ang)
'MsgBox (Sin(ang) ^ 2 + Cos(ang) ^ 2) ^ 0.5
'MsgBox Sin(ang) & " " & (1 - Cos(ang) ^ 2) ^ 0.5

'MsgBox Atn(Sin(ang) / ((1 - Sin(ang) ^ 2) ^ 0.5))

mysin = Sin(ang)

'MsgBox Atn(Sin(ang) / ((1 - Sin(ang) ^ 2) ^ 0.5))

yo = 0.5

MsgBox Atn(yo / ((1 - yo ^ 2) ^ 0.5))
End Sub

« Last Edit: May 02, 2014, 11:54:18 AM by Botsareus »

Offline MysticalDumpling

  • Bot Destroyer
  • ***
  • Posts: 205
  • Kurwa chuj!
    • View Profile
Re: How can you approximate sin-1?
« Reply #11 on: May 02, 2014, 02:37:30 PM »
i can't help but notice that the equation doesn't factor in the vel of any bot as far as i can tell. this could help.

I know. I made a new formula. And *.refvelscalar is sprinkled through both equations.
To być albo nie być, oto jest ze pytanie

Offline MysticalDumpling

  • Bot Destroyer
  • ***
  • Posts: 205
  • Kurwa chuj!
    • View Profile
Re: How can you approximate sin-1?
« Reply #12 on: May 02, 2014, 03:02:59 PM »
My new formula in DB
If Nums is right an arccos ~= 1, then
Code: [Select]
1600   *.refxpos *.refypos angle mult 2 pow *.refvelscalar 2 pow add *.refxpos *.refypos angle *.refvelscalar mult 2 mult *.refaim *.aim sub cos mult 40 *.refvelscalar mult div 2 pow *.refxpos *.refypos angle 2 pow add 1600   *.refxpos *.refypos angle mult 2 pow *.refvelscalar 2 pow add *.refxpos *.refypos angle *.refvelscalar mult 2 mult *.refaim *.aim sub cos mult 40 *.refvelscalar mult div*.refvelscalar mult 2 pow 80 ]1600   *.refxpos *.refypos angle mult 2 pow *.refvelscalar 2 pow add *.refxpos *.refypos angle *.refvelscalar mult 2 mult *.refaim *.aim sub cos mult 40 *.refvelscalar mult div 2 pow mult 2 *.refxpos *.refypos angle mult mult div  Otherwise, it has to be
Code: [Select]
22 14 div 1600   *.refxpos *.refypos angle mult 2 pow *.refvelscalar 2 pow add *.refxpos *.refypos angle *.refvelscalar mult 2 mult *.refaim *.aim sub cos mult 40 *.refvelscalar mult div 2 pow *.refxpos *.refypos angle 2 pow add 1600   *.refxpos *.refypos angle mult 2 pow *.refvelscalar 2 pow add *.refxpos *.refypos angle *.refvelscalar mult 2 mult *.refaim *.aim sub cos mult 40 *.refvelscalar mult div*.refvelscalar mult 2 pow 80 ]1600   *.refxpos *.refypos angle mult 2 pow *.refvelscalar 2 pow add *.refxpos *.refypos angle *.refvelscalar mult 2 mult *.refaim *.aim sub cos mult 40 *.refvelscalar mult div 2 pow mult 2 *.refxpos *.refypos angle mult mult div sub 1600   *.refxpos *.refypos angle mult 2 pow *.refvelscalar 2 pow add *.refxpos *.refypos angle *.refvelscalar mult 2 mult *.refaim *.aim sub cos mult 40 *.refvelscalar mult div 2 pow *.refxpos *.refypos angle 2 pow add 1600   *.refxpos *.refypos angle mult 2 pow *.refvelscalar 2 pow add *.refxpos *.refypos angle *.refvelscalar mult 2 mult *.refaim *.aim sub cos mult 40 *.refvelscalar mult div*.refvelscalar mult 2 pow 80 ]1600   *.refxpos *.refypos angle mult 2 pow *.refvelscalar 2 pow add *.refxpos *.refypos angle *.refvelscalar mult 2 mult *.refaim *.aim sub cos mult 40 *.refvelscalar mult div 2 pow mult 2 *.refxpos *.refypos angle mult mult div 3 pow 6 div subAcck. I hate reverse polish with equations like this. I probably misplaced something imp.  :wacko:


Now, how to use the darn thing....

vector math sounds like a good idea.
To być albo nie być, oto jest ze pytanie

Offline MysticalDumpling

  • Bot Destroyer
  • ***
  • Posts: 205
  • Kurwa chuj!
    • View Profile
Re: How can you approximate sin-1?
« Reply #13 on: May 02, 2014, 03:03:57 PM »
While I was typing that post, a conversation happened in real time. I have never seen anything like it before...
To być albo nie być, oto jest ze pytanie

Offline Shadowgod2

  • Bot Destroyer
  • ***
  • Posts: 387
    • View Profile
Re: How can you approximate sin-1?
« Reply #14 on: May 02, 2014, 03:06:53 PM »
it happens :P