Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-21-2011, 09:06 PM
iBeatz iBeatz is offline
Kavan
iBeatz's Avatar
Join Date: Dec 2010
Location: Northern Ireland, UK
Posts: 154
iBeatz will become famous soon enough
Send a message via Yahoo to iBeatz
Sin and cos functions wrong?

I've been doing an angle-based movement project, and haven't really done anything major with angles in GScript until now.
When I use a variable which is equal to 180 and take the sine of it using sin(), instead of echoing 0 for the sine value of 180 (which I know it should), it echoes a value of -0.801.
The same goes for the cosine value of 180. It echoes a value of -0.598 instead of -1.

Any reason for this, or is there something wrong with the functions?
__________________

Intelligence without ambition is like a bird without wings.

Reply With Quote
  #2  
Old 11-21-2011, 09:18 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Use radian values, not degrees. pi is a built-in variable that'll help a lot.
__________________
Reply With Quote
  #3  
Old 11-21-2011, 10:48 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
There's also:

degtorad(angle);
radtodeg(angle);

To convert back and forth. You really shouldn't need to do that though.
__________________
Quote:
Reply With Quote
  #4  
Old 11-22-2011, 12:13 AM
iBeatz iBeatz is offline
Kavan
iBeatz's Avatar
Join Date: Dec 2010
Location: Northern Ireland, UK
Posts: 154
iBeatz will become famous soon enough
Send a message via Yahoo to iBeatz
Quote:
Originally Posted by fowlplay4 View Post
There's also:

degtorad(angle);
radtodeg(angle);

To convert back and forth. You really shouldn't need to do that though.
I'm using degtorad().
I just feel more comfortable using degrees than radian values.
__________________

Intelligence without ambition is like a bird without wings.

Reply With Quote
  #5  
Old 11-22-2011, 12:29 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by iBeatz View Post
I'm using degtorad().
I just feel more comfortable using degrees than radian values.
Well yeah of course degtorad(45) is a lot easier to read/understand than say (pi / 4) for 45 degrees.

Keep in mind that pi is equal to a 180 degrees and it's easy enough to calculate degrees using it. I.e: 360 (pi * 2) or 90 (pi / 2) or 45 (pi / 4) and so on.
__________________
Quote:
Reply With Quote
  #6  
Old 11-22-2011, 05:36 PM
Sinkler Sinkler is offline
.
Sinkler's Avatar
Join Date: Jul 2004
Location: Washington, D.C.
Posts: 683
Sinkler is a jewel in the roughSinkler is a jewel in the rough
Send a message via AIM to Sinkler
Quote:
Originally Posted by Crow View Post
Use radian values, not degrees. pi is a built-in variable that'll help a lot.
I know nothing about scripting, but does it have something to do with units? In calculus, we're not permitted to use degrees due to the units associated with degrees. Is this a fair assumption?

--This is coming from an unknowledgeable person in regards to scripting--
__________________
Hello!

If you need to get in contact with me, please send an e-mail to: [email protected]



"He who knows only his own side of the case knows little of that."

-John Stuart Mill
Reply With Quote
  #7  
Old 11-22-2011, 05:59 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Sinkler View Post
I know nothing about scripting, but does it have something to do with units? In calculus, we're not permitted to use degrees due to the units associated with degrees. Is this a fair assumption?
You know how your calculator has a mode for radians and a mode for degrees? In programming, radians are almost always used.

I don't really know what you mean by "units associated with degrees" but that sounds like a silly reason to use radians.
__________________
Reply With Quote
  #8  
Old 11-22-2011, 11:08 PM
Sinkler Sinkler is offline
.
Sinkler's Avatar
Join Date: Jul 2004
Location: Washington, D.C.
Posts: 683
Sinkler is a jewel in the roughSinkler is a jewel in the rough
Send a message via AIM to Sinkler
Quote:
Originally Posted by cbk1994 View Post
You know how your calculator has a mode for radians and a mode for degrees? In programming, radians are almost always used.

I don't really know what you mean by "units associated with degrees" but that sounds like a silly reason to use radians.
When using related rates, some problems (if you use degrees) can end up with:

"___ degrees/hour"

Which doesn't make sense (if we're talking angular calculus). That's why Radians is the preferable mode in calculus. There are no units.
__________________
Hello!

If you need to get in contact with me, please send an e-mail to: [email protected]



"He who knows only his own side of the case knows little of that."

-John Stuart Mill
Reply With Quote
  #9  
Old 11-23-2011, 12:58 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Sinkler View Post
Which doesn't make sense (if we're talking angular calculus). That's why Radians is the preferable mode in calculus. There are no units.
Radians are units . You just generally don't write it because it's assumed. There's also radians per second and similar.
__________________
Reply With Quote
  #10  
Old 11-23-2011, 01:17 AM
Sinkler Sinkler is offline
.
Sinkler's Avatar
Join Date: Jul 2004
Location: Washington, D.C.
Posts: 683
Sinkler is a jewel in the roughSinkler is a jewel in the rough
Send a message via AIM to Sinkler
Quote:
Originally Posted by cbk1994 View Post
Radians are units . You just generally don't write it because it's assumed. There's also radians per second and similar.
Radians have a mathematical "naturalness" that leads to a more elegant formulation of a number of important results.
__________________
Hello!

If you need to get in contact with me, please send an e-mail to: [email protected]



"He who knows only his own side of the case knows little of that."

-John Stuart Mill
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:33 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.