Game Maker Community YoYo Games

Welcome Guest ( Log In | Register )

> Novice Forum Rules

Novice and intermediate users who are using Drag & Drop action icons, or still learning GML, can get help from more experienced members.

Please READ the Novice Q&A Forum Rules prior to posting. And remember that the General GMC Rules apply here too.

 
Reply to this topicStart new topic
Problem With Radtodeg() Function, *Solved*
Mak6nd
post Nov 6 2009, 06:59 PM
Post #1


GMC Member
Group Icon

Group: GMC Member
Posts: 43
Joined: 19-April 08
Member No.: 104693



This problem has been solved now thanks.

---
Hi, I've just tryed out the radtodeg() function and I've noticed that it isn't working properly for me.

sin(x), cos(x) and tan(x) all return the answer in radians. So I tested them and set my calculator mode to radians and tried each of them. Game maker returned the same numbers as my calculator returned. However I want the answer to be in degrees so I used the radtodeg() function.

radtodeg(sin(55)) on Game maker returned -57.2817519800

I set my calculator mode to degrees and tried sin(55), the answer I got was 0.819152044.

I have the same problem when using the cos and tan functions. I'm sure sin, cos and tan all work fine (give correct answer in radians) but it's just radtodeg() that doesn't work.

Please help!

Thanks. snitch.gif



This post has been edited by Mak6nd: Nov 6 2009, 08:10 PM
Go to the top of the page
 
+Quote Post
ramses12
post Nov 6 2009, 07:06 PM
Post #2


Pro Music Composer
Group Icon

Group: GMC Member
Posts: 1394
Joined: 17-April 09
From: an ancient world
Member No.: 131883



Don't you know that sin() doesn't return an angle?!
It has an angle as the argument, which has to be altered by degtorag().

Edit: sin(degtorad(angle)); has a valid value. What are you trying to do anyway?

This post has been edited by ramses12: Nov 6 2009, 07:07 PM
Go to the top of the page
 
+Quote Post
jabelar
post Nov 6 2009, 07:07 PM
Post #3


GMC Member
Group Icon

Group: GMC Member
Posts: 1909
Joined: 3-October 07
Member No.: 89861



QUOTE (Mak6nd @ Nov 6 2009, 10:59 AM) *
Hi, I've just tryed out the radtodeg() function and I've noticed that it isn't working properly for me.

sin(x), cos(x) and tan(x) all return the answer in radians. So I tested them and set my calculator mode to radians and tried each of them. Game maker returned the same numbers as my calculator returned. However I want the answer to be in degrees so I used the radtodeg() function.

radtodeg(sin(55)) on Game maker returned -57.2817519800

I set my calculator mode to degrees and tried sin(55), the answer I got was 0.819152044.

I have the same problem when using the cos and tan functions. I'm sure sin, cos and tan all work fine (give correct answer in radians) but it's just radtodeg() that doesn't work.

Please help!

Thanks. snitch.gif


You're using radtodeg() in the wrong place. 55 is in degrees, and you need to convert that to radians. In game maker you should use:
CODE
sin(degtorad(55))
Go to the top of the page
 
+Quote Post
ramses12
post Nov 6 2009, 07:11 PM
Post #4


Pro Music Composer
Group Icon

Group: GMC Member
Posts: 1394
Joined: 17-April 09
From: an ancient world
Member No.: 131883



And if you need an angle returned, you should probably know what trigonometrical functions like arcsin(), arccos() and arctan() are for.
Go to the top of the page
 
+Quote Post
Mak6nd
post Nov 6 2009, 07:59 PM
Post #5


GMC Member
Group Icon

Group: GMC Member
Posts: 43
Joined: 19-April 08
Member No.: 104693



Ramses, I do know trigonometry and how to find angles but I was just testing for something I plan to make with Game maker.

I've tried out sin(degtorad(55)), and it works so thanks both of you for your help.

If I wanted to do the inverse of sine then I could use arcsin(), but could someone please tell me how to do so?

EDIT: I've figured it out now. whistle.gif

Thanks. medieval.gif

This post has been edited by Mak6nd: Nov 6 2009, 08:08 PM
Go to the top of the page
 
+Quote Post
ramses12
post Nov 7 2009, 09:52 AM
Post #6


Pro Music Composer
Group Icon

Group: GMC Member
Posts: 1394
Joined: 17-April 09
From: an ancient world
Member No.: 131883



QUOTE
Ramses, I do know trigonometry and how to find angles but I was just testing for something I plan to make with Game maker.

I've tried out sin(degtorad(55)), and it works so thanks both of you for your help.

Well ok didn't say you don't know that, just trying to clarify things for novice users who may read this.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 22nd November 2009 - 12:37 PM