I have been struggling for hours trying to get this to work. Now I just don't know what to do anymore so maybe you guys can help me.
Math isn't my strongpoint, so little warning upfront.
[URL]https://prnt.sc/jqu042[/URL]
In the picture, I did sin(90). Even with low precision, I feel that a precision of 0.89 is pretty darn off. It should be 1 right?
For some reason, whenever I run the fsin or fcos instruction, it never seems to give me the right results.
Is there something I am missing in order to have the right values being displayed?
EDIT:
Apparently I had to do some division before I could get the right sine and cosine, not sure if it'll help anyone, but for me the value divided by '56' did the trick.
So this can be closed for all I know
Sine and Cosine
- WhiteSnoop
- Table Makers
- Posts: 55
- Joined: Wed May 31, 2017 11:18 pm
- Reputation: 48
Sine and Cosine
Last edited by WhiteSnoop on Tue Jun 05, 2018 12:39 am, edited 3 times in total.
Sine and Cosine
The exact value to divide by is 180/pi ;) In many cases sine/cosine functions take their argument in the unit rad(ians) and not in deg(ree). So you need to convert deg to rad to put it into the function and that's done by multiplying the deg value by pi and dividing it by 180°. Google "radian" for more background.
- WhiteSnoop
- Table Makers
- Posts: 55
- Joined: Wed May 31, 2017 11:18 pm
- Reputation: 48
Sine and Cosine
Thanks seikur0, I figured this out later aswell. But still thank you for the help. I learned some maths the other day and indeed I thought I could just convert from deg haha.
What I sort of end up doing and to maybe help out others.
[CODE=nasm]
push #18 // mult
push #180 // divider
fld dword ptr [ecx+10] // rotation
fild dword ptr [esp] // divider (int to float)
fldpi // load PI
fdivp // 180 / PI
fdivp // rot / divider
fsin // sine
fimul [esp+4] // sine * mult
fadd [ecx] // add original X axis
fstp [ecx]
add esp,8
[/CODE]
Note: even worse was that the game already stored the values. So eventually I didn't need all this. But hey I learnt something!
What I sort of end up doing and to maybe help out others.
[CODE=nasm]
push #18 // mult
push #180 // divider
fld dword ptr [ecx+10] // rotation
fild dword ptr [esp] // divider (int to float)
fldpi // load PI
fdivp // 180 / PI
fdivp // rot / divider
fsin // sine
fimul [esp+4] // sine * mult
fadd [ecx] // add original X axis
fstp [ecx]
add esp,8
[/CODE]
Note: even worse was that the game already stored the values. So eventually I didn't need all this. But hey I learnt something!
Last edited by WhiteSnoop on Tue Jun 05, 2018 11:55 pm, edited 5 times in total.
Sine and Cosine
^ Was about to ask "can't you find the already calculated values?" :D
Who is online
Users browsing this forum: No registered users