sin() and cos() functions in v3.8B
sin() and cos() functions in v3.8B
please someone check the sin() and cos() functions in ver3.8B
it seems that there is a difference in calculating these functions in new version versus version 3.72
regards
Reza
it seems that there is a difference in calculating these functions in new version versus version 3.72
regards
Reza
What difference are you talking about... I'm using them in this game I'm making, and I didn't see any difference when I upgraded til 3.8 (3.79Beta)
-Lars
-Lars
AMD Athlon XP2400, 512 MB RAM, Hercules 3D Prophet 9600 256MB RAM, WinXP
PIII 800MHz, 320 MB RAM, Nvidia Riva Tnt 2 Mach 64 (32MB), WinXP + Linux
17" iMac, 1.8 GHz G5, 512 MB DDR-RAM, 80 GB HD, 64 MB Geforce FX 5200, SuperDrive, OSX
i used this code in my program:
pi4=atan(1)
for direction=0 to 7
x=int(cos(direction*pi4)+.5)
y=int(sin(direction*pi4)+.5)
next direction
here is the result for x in version 3.72 and 3.8b
direction 3.72 3.8b
---------- ------ ------
0 1 1
1 1 1
2 0 0
3 -1 0
4 -1 0
5 -1 0
6 0 0
7 1 1
any idea?!
regards
Reza
pi4=atan(1)
for direction=0 to 7
x=int(cos(direction*pi4)+.5)
y=int(sin(direction*pi4)+.5)
next direction
here is the result for x in version 3.72 and 3.8b
direction 3.72 3.8b
---------- ------ ------
0 1 1
1 1 1
2 0 0
3 -1 0
4 -1 0
5 -1 0
6 0 0
7 1 1
any idea?!
regards
Reza
I don't know if 3.72 didn't use radian values, but if it didn't, just try multiplying your direction with (3.141593 / 180)...
(probably won't help you, but it's worth a shot..)
-Lars
(probably won't help you, but it's worth a shot..)
-Lars
AMD Athlon XP2400, 512 MB RAM, Hercules 3D Prophet 9600 256MB RAM, WinXP
PIII 800MHz, 320 MB RAM, Nvidia Riva Tnt 2 Mach 64 (32MB), WinXP + Linux
17" iMac, 1.8 GHz G5, 512 MB DDR-RAM, 80 GB HD, 64 MB Geforce FX 5200, SuperDrive, OSX
I can't figure it out.. are you sure you're using the same formula?!
I tried your code, but it returned the 3.8 result as you wrote..
-Lars
I tried your code, but it returned the 3.8 result as you wrote..
-Lars
AMD Athlon XP2400, 512 MB RAM, Hercules 3D Prophet 9600 256MB RAM, WinXP
PIII 800MHz, 320 MB RAM, Nvidia Riva Tnt 2 Mach 64 (32MB), WinXP + Linux
17" iMac, 1.8 GHz G5, 512 MB DDR-RAM, 80 GB HD, 64 MB Geforce FX 5200, SuperDrive, OSX
I got almost the same results as you did in 3.8
one number differs though..
I got the sequence: 1 1 0 0 0 0 1 1
-Lars
one number differs though..
I got the sequence: 1 1 0 0 0 0 1 1
-Lars
AMD Athlon XP2400, 512 MB RAM, Hercules 3D Prophet 9600 256MB RAM, WinXP
PIII 800MHz, 320 MB RAM, Nvidia Riva Tnt 2 Mach 64 (32MB), WinXP + Linux
17" iMac, 1.8 GHz G5, 512 MB DDR-RAM, 80 GB HD, 64 MB Geforce FX 5200, SuperDrive, OSX
1.) Make sure you declare floats as floats
when you set:
pi4=ATan(1)
x=Int(Cos(direction*pi4) + 0.5)
result: 11000011
but
when you set:
pi4.f=ATan(1)
x=Int(Cos(direction*pi4) + 0.5)
result: 11000001
2.) Use:
x=Round(Cos(direction*pi4) + 0.5, 0)
instead of
x=Int(Cos(direction*pi4) + 0.5)
to get the same result as v3.72
The Handbook says:
Int()
Returns the interger part of a float number.
Example
Result = Int(10.565) ; Will return '10'
...
so if you look at the float values the v3.72 INT(x) command didn't work right...
when you set:
pi4=ATan(1)
x=Int(Cos(direction*pi4) + 0.5)
result: 11000011
but
when you set:
pi4.f=ATan(1)
x=Int(Cos(direction*pi4) + 0.5)
result: 11000001
2.) Use:
x=Round(Cos(direction*pi4) + 0.5, 0)
instead of
x=Int(Cos(direction*pi4) + 0.5)
to get the same result as v3.72
The Handbook says:
Int()
Returns the interger part of a float number.
Example
Result = Int(10.565) ; Will return '10'
...
so if you look at the float values the v3.72 INT(x) command didn't work right...
I am to provide the public with beneficial shocks.
Alfred Hitshock


