Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / strange sine and cosine values

Author
Message
Dark Lord
19
Years of Service
User Offline
Joined: 19th Aug 2005
Location: Australia
Posted: 24th Sep 2006 01:46 Edited at: 24th Sep 2006 01:51
Below are values returned by the dbSin() and dbCos() functions.

I'm just wondering if anyone else gets values like this when using the two functions? I am using trig to position objects with an angle and a step value in 3d space, any help would be appreciated

Sin 0 = 1
Sin 90 = -4.37
Sin 180 = -1
Sin 270 = 1.192
Sin 360 = 1

Cos 0 = 0
Cos 90 = 1
Cos 180 = -8.74
Cos 270 = -1
Cos 360 = 1.74

The values returned by sine and cosine are supposed to cycle between 1 and -1, so there must be something wrong with the functions.

[edit] My program doesn't work properly. Here is the code:
Wilvis
18
Years of Service
User Offline
Joined: 6th Aug 2006
Location:
Posted: 24th Sep 2006 02:10
I had Problems rotating my camera around an object using dgk sin and cos functions so i just used the c++ ones.
APEXnow
Retired Moderator
21
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 24th Sep 2006 02:25
include <math.h> and use the cos/sin acos/asin functions.

Paul.

Dark Lord
19
Years of Service
User Offline
Joined: 19th Aug 2005
Location: Australia
Posted: 24th Sep 2006 03:06 Edited at: 24th Sep 2006 03:42
Thanks for the help. Do the cosine and sine functions work with radians or degrees? Because, if they work with degrees, then i've a feeling something strange is going on here:




The function returns a value of '-0.59', it should return -1, shouldn't it?

[edit] ahhh, the math sine and cosine functions use radians, hence cos(PI) should equal 1, which it does. Here is the updated working code:



Just one more question I found this line '#define M_PI 3.14159265358979323846' in the math.h file. However, when I try to use M_PI in my degrees_to_radians function instead of the PI I defined myself, I get an undeclared identifier error. Does anyone know how to fix this?
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 24th Sep 2006 11:27
dbSin and dbCos use degrees.

sin and cos (in #math) use radians.

Wibble
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 3rd Oct 2006 06:55
defines are only valid during compilation of the source file that defines them. Put "#include <math.h>" in the offended file's list of include files.
APEXnow
Retired Moderator
21
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 3rd Oct 2006 15:32
Did you actually read this thread?

Miguel Melo
19
Years of Service
User Offline
Joined: 8th Aug 2005
Location:
Posted: 3rd Oct 2006 17:58
Oh, I know, I know... err... you should put #include <math.h> at the top of the file.

I have vague plans for World Domination

Login to post a reply

Server time is: 2024-11-19 08:28:06
Your offset time is: 2024-11-19 08:28:06