sin() and cos() functions in v3.8B

Everything else that doesn't fall into one of the other PB categories.
Behnood
User
User
Posts: 72
Joined: Fri Apr 25, 2003 10:07 pm
Location: Australia
Contact:

sin() and cos() functions in v3.8B

Post by Behnood »

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
LarsG
Enthusiast
Enthusiast
Posts: 713
Joined: Mon Jun 02, 2003 1:06 pm
Location: Norway
Contact:

Post by LarsG »

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

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
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Post by dmoc »

Me too, sin & cos all over the place and seems ok.
Behnood
User
User
Posts: 72
Joined: Fri Apr 25, 2003 10:07 pm
Location: Australia
Contact:

Post by Behnood »

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
LarsG
Enthusiast
Enthusiast
Posts: 713
Joined: Mon Jun 02, 2003 1:06 pm
Location: Norway
Contact:

Post by LarsG »

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

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
Behnood
User
User
Posts: 72
Joined: Fri Apr 25, 2003 10:07 pm
Location: Australia
Contact:

Post by Behnood »

sure atan() (or arctan()) will return result in radian in all languages.
may be the problem is in the int() function
any idea?
regards
Reza
LarsG
Enthusiast
Enthusiast
Posts: 713
Joined: Mon Jun 02, 2003 1:06 pm
Location: Norway
Contact:

Post by LarsG »

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

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
Behnood
User
User
Posts: 72
Joined: Fri Apr 25, 2003 10:07 pm
Location: Australia
Contact:

Post by Behnood »

what do you mean it returned 3.8 results?!
the problem is diferences between 3.72 results and 3.8 results

direction 0 1 2 3 4 5 6 7
3.72 1 1 0 -1 -1 -1 0 1
3.8 1 1 0 0 0 0 0 1
LarsG
Enthusiast
Enthusiast
Posts: 713
Joined: Mon Jun 02, 2003 1:06 pm
Location: Norway
Contact:

Post by LarsG »

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

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
Behnood
User
User
Posts: 72
Joined: Fri Apr 25, 2003 10:07 pm
Location: Australia
Contact:

Post by Behnood »

ok, but i wrote my program to get results like what i got from v3.72!
why formula return different result in new version?!
LarsG
Enthusiast
Enthusiast
Posts: 713
Joined: Mon Jun 02, 2003 1:06 pm
Location: Norway
Contact:

Post by LarsG »

Dunno.. maybe ask Fred..

-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
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

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 :wink:

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
Behnood
User
User
Posts: 72
Joined: Fri Apr 25, 2003 10:07 pm
Location: Australia
Contact:

Post by Behnood »

so there was a bug in int function (v3.72) and nothing wrong with 3.8 beta about this function, yes?
thanks
regards
Reza
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

You're welcome :wink:
Hope that now all works well.

I am to provide the public with beneficial shocks.
Alfred Hitshock
Behnood
User
User
Posts: 72
Joined: Fri Apr 25, 2003 10:07 pm
Location: Australia
Contact:

Post by Behnood »

yes, those are ok now.
thanks
Post Reply