Difference between revisions of "Talk:Simulating new functions"
Jump to navigation
Jump to search
no edit summary
imported>JustTim |
imported>Maian |
||
Line 191: | Line 191: | ||
BTW: If there is something you'd like to change or contribute to the article or if you know of a good way to write a simplier example don't hesitate to modify the article directly. I know the article lacks a professional writing style (presumably due to me not being a native english-speaker) and it would be cool if someone could help me to bring this into a professional, more wiki-like (and error-free) form. --[[User:JustTim|JustTim]] 15:16, 8 May 2006 (EDT) | BTW: If there is something you'd like to change or contribute to the article or if you know of a good way to write a simplier example don't hesitate to modify the article directly. I know the article lacks a professional writing style (presumably due to me not being a native english-speaker) and it would be cool if someone could help me to bring this into a professional, more wiki-like (and error-free) form. --[[User:JustTim|JustTim]] 15:16, 8 May 2006 (EDT) | ||
This is a script I made but ended up never using once I discovered the getHeadingAngle function (so it's rather untested and probably has bugs). It's basically a lookup table, one row for a degree (so the script is large), except since there are no arrays, I made the look up act as a binary search. It also doesn't use the quest result script thing - I'm using the method I described above. | |||
<pre>scn ArcTanScript | |||
; by Maian | |||
float x | |||
float y | |||
float result | |||
float ratio | |||
begin GameMode | |||
if x == 0 | |||
if y >= 0 | |||
set result to 90 | |||
else | |||
set result to 270 | |||
endif | |||
return | |||
endif | |||
set ratio to y / x | |||
if ratio < 0 | |||
set ratio to -ratio | |||
endif | |||
if ratio < 1.018 | |||
if ratio < 0.414 | |||
if ratio < 0.203 | |||
if ratio < 0.096 | |||
if ratio < 0.044 | |||
if ratio < 0.009 | |||
set result to 0 | |||
elseif ratio < 0.026 | |||
set result to 1 | |||
else | |||
set result to 2 | |||
endif | |||
else ; 0.044 | |||
if ratio < 0.061 | |||
set result to 3 | |||
elseif ratio < 0.079 | |||
set result to 4 | |||
else | |||
set result to 5 | |||
endif | |||
endif | |||
else ; 0.096 | |||
if ratio < 0.149 | |||
if ratio < 0.114 | |||
set result to 6 | |||
elseif ratio < 0.132 | |||
set result to 7 | |||
else | |||
set result to 8 | |||
endif | |||
else ; 0.149 | |||
if ratio < 0.167 | |||
set result to 9 | |||
elseif ratio < 0.185 | |||
set result to 10 | |||
else | |||
set result to 11 | |||
endif | |||
endif | |||
endif | |||
else ; 0.203 | |||
if ratio < 0.296 | |||
if ratio < 0.24 | |||
if ratio < 0.222 | |||
set result to 12 | |||
else | |||
set result to 13 | |||
endif | |||
else ; 0.24 | |||
if ratio < 0.259 | |||
set result to 14 | |||
elseif ratio < 0.277 | |||
set result to 15 | |||
else | |||
set result to 16 | |||
endif | |||
endif | |||
else ; 0.296 | |||
if ratio < 0.354 | |||
if ratio < 0.315 | |||
set result to 17 | |||
elseif ratio < 0.335 | |||
set result to 18 | |||
else | |||
set result to 19 | |||
endif | |||
else ; 0.354 | |||
if ratio < 0.374 | |||
set result to 20 | |||
elseif ratio < 0.394 | |||
set result to 21 | |||
else | |||
set result to 22 | |||
endif | |||
endif | |||
endif | |||
endif | |||
else ; 0.414 | |||
if ratio < 0.662 | |||
if ratio < 0.521 | |||
if ratio < 0.456 | |||
if ratio < 0.435 | |||
set result to 23 | |||
else | |||
set result to 24 | |||
endif | |||
else ; 0.456 | |||
if ratio < 0.477 | |||
set result to 25 | |||
elseif ratio < 0.499 | |||
set result to 26 | |||
else | |||
set result to 27 | |||
endif | |||
endif | |||
else ; 0.521 | |||
if ratio < 0.589 | |||
if ratio < 0.543 | |||
set result to 28 | |||
elseif ratio < 0.566 | |||
set result to 29 | |||
else | |||
set result to 30 | |||
endif | |||
else ; 0.589 | |||
if ratio < 0.613 | |||
set result to 31 | |||
elseif ratio < 0.637 | |||
set result to 32 | |||
else | |||
set result to 33 | |||
endif | |||
endif | |||
endif | |||
else ; 0.662 | |||
if ratio < 0.824 | |||
if ratio < 0.74 | |||
if ratio < 0.687 | |||
set result to 34 | |||
elseif ratio < 0.713 | |||
set result to 35 | |||
else | |||
set result to 36 | |||
endif | |||
else ; 0.74 | |||
if ratio < 0.767 | |||
set result to 37 | |||
elseif ratio < 0.795 | |||
set result to 38 | |||
else | |||
set result to 39 | |||
endif | |||
endif | |||
else ; 0.824 | |||
if ratio < 0.916 | |||
if ratio < 0.854 | |||
set result to 40 | |||
elseif ratio < 0.885 | |||
set result to 41 | |||
else | |||
set result to 42 | |||
endif | |||
else ; 0.916 | |||
if ratio < 0.949 | |||
set result to 43 | |||
elseif ratio < 0.983 | |||
set result to 44 | |||
else | |||
set result to 45 | |||
endif | |||
endif | |||
endif | |||
endif | |||
endif | |||
else ; 1.018 | |||
if ratio < 2.414 | |||
if ratio < 1.511 | |||
if ratio < 1.213 | |||
if ratio < 1.091 | |||
if ratio < 1.054 | |||
set result to 46 | |||
else | |||
set result to 47 | |||
endif | |||
else ; 1.091 | |||
if ratio < 1.13 | |||
set result to 48 | |||
elseif ratio < 1.171 | |||
set result to 49 | |||
else | |||
set result to 50 | |||
endif | |||
endif | |||
else ; 1.213 | |||
if ratio < 1.351 | |||
if ratio < 1.257 | |||
set result to 51 | |||
elseif ratio < 1.303 | |||
set result to 52 | |||
else | |||
set result to 53 | |||
endif | |||
else ; 1.351 | |||
if ratio < 1.402 | |||
set result to 54 | |||
elseif ratio < 1.455 | |||
set result to 55 | |||
else | |||
set result to 56 | |||
endif | |||
endif | |||
endif | |||
else ; 1.511 | |||
if ratio < 1.842 | |||
if ratio < 1.632 | |||
if ratio < 1.57 | |||
set result to 57 | |||
else | |||
set result to 58 | |||
endif | |||
else ; 1.632 | |||
if ratio < 1.698 | |||
set result to 59 | |||
elseif ratio < 1.767 | |||
set result to 60 | |||
else | |||
set result to 61 | |||
endif | |||
endif | |||
else ; 1.842 | |||
if ratio < 2.097 | |||
if ratio < 1.921 | |||
set result to 62 | |||
elseif ratio < 2.006 | |||
set result to 63 | |||
else | |||
set result to 64 | |||
endif | |||
else ; 2.097 | |||
if ratio < 2.194 | |||
set result to 65 | |||
elseif ratio < 2.3 | |||
set result to 66 | |||
else | |||
set result to 67 | |||
endif | |||
endif | |||
endif | |||
endif | |||
else ; 2.414 | |||
if ratio < 4.915 | |||
if ratio < 3.172 | |||
if ratio < 2.675 | |||
if ratio < 2.539 | |||
set result to 68 | |||
elseif ratio < 2.006 | |||
set result to 69 | |||
endif | |||
else ; 2.675 | |||
if ratio < 2.824 | |||
set result to 70 | |||
elseif ratio < 2.989 | |||
set result to 71 | |||
else | |||
set result to 72 | |||
endif | |||
endif | |||
else ; 3.172 | |||
if ratio < 3.867 | |||
if ratio < 3.376 | |||
set result to 73 | |||
elseif ratio < 3.606 | |||
set result to 74 | |||
else | |||
set result to 75 | |||
endif | |||
else ; 3.867 | |||
if ratio < 4.165 | |||
set result to 76 | |||
elseif ratio < 4.511 | |||
set result to 77 | |||
else | |||
set result to 78 | |||
endif | |||
endif | |||
endif | |||
else ; 4.915 | |||
if ratio < 10.385 | |||
if ratio < 6.691 | |||
if ratio < 5.396 | |||
set result to 79 | |||
elseif ratio < 5.976 | |||
set result to 80 | |||
else | |||
set result to 81 | |||
endif | |||
else ; 6.691 | |||
if ratio < 7.596 | |||
set result to 82 | |||
elseif ratio < 8.777 | |||
set result to 83 | |||
else | |||
set result to 84 | |||
endif | |||
endif | |||
else ; 10.385 | |||
if ratio < 22.904 | |||
if ratio < 10.385 | |||
set result to 85 | |||
elseif ratio < 12.706 | |||
set result to 86 | |||
else | |||
set result to 87 | |||
endif | |||
else ; 22.904 | |||
if ratio < 38.188 | |||
set result to 88 | |||
elseif ratio < 114.589 | |||
set result to 89 | |||
else | |||
set result to 90 | |||
endif | |||
endif | |||
endif | |||
endif | |||
endif | |||
endif | |||
if x < 0 && y < 0 | |||
set result to result + 180 | |||
elseif x < 0 | |||
set result to -result + 180 | |||
elseif y < 0 | |||
set result to -result + 360 | |||
else | |||
set result to result | |||
endif | |||
end</pre> | |||
--[[User:Maian|Maian]] 16:50, 8 May 2006 (EDT) |