Sign in to follow this  
Followers 0
monoceres

Using Sin() with degrees

7 posts in this topic

#1 ·  Posted (edited)

I'm currently writing a simple triangle solver app, but I'm having troubles when using the law of sines ( a/Sin(A) = b/Sin(B) ).

Here's my problem:

#include <math.au3>
; When testing this on my calculator I get around 19 which is correct but this doesn't (-4.03)
MsgBox(0,"",(10/_Degree(Sin(10)))*_Degree(Sin(160)))
; Oh and neither does this:
MsgBox(0,"",(10/Sin(10))*Sin(160))
; This works however:
MsgBox(0,"",(10/_Degree(Sin(10)))*_Degree(Sin(10)))

I know it's the stupid radians fault but how do I fix it?

Edited by monoceres

Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites



When you use the Sin() function, you must always give it a paramater in radians, and it will always return a number in radians. I see at some points you are using 160 which is most likely degrees. Make sure you pay close attention to which numbers you use as paramaters.

Share this post


Link to post
Share on other sites

When you use the Sin() function, you must always give it a paramater in radians, and it will always return a number in radians. I see at some points you are using 160 which is most likely degrees. Make sure you pay close attention to which numbers you use as paramaters.

Of course how foolish of me.

Thanks for looking into it :D


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

Take a look at this:

#463161

Share this post


Link to post
Share on other sites

When you use the Sin() function, you must always give it a paramater in radians, and it will always return a number in radians. I see at some points you are using 160 which is most likely degrees. Make sure you pay close attention to which numbers you use as paramaters.

@Everyone, especially monoceres

This is not so. Sin(x) does not return a number in any particular unit. It merely returns the value of the ratio of the length of the opposite side to the length of the hypotenuse of one of the non right angles in a right triangle whose angle measure is x. The angle measure is traditionally given in radians for Sine, Cosine, and Tangent functions because radians are the natural units of a circle. The only reason we use degrees is because the greeks had some fascination with using degrees instead of the more natural radians.

In the world of the unit circle, Sin() is the value of the y coordinate on the unit circle while Cos() is the value of the x coordinate on the unit circle. Tan() is equal to the slope of the angle on the unit circle.

I know you are frustrated about using radians instead of degrees, but please use the radians. They really are much more natural and much better than degrees.

Anyway, to help you, i have made this:

ConsoleWrite(Round(Cos(_DegreesToRadians(90)),2)&@LF)

ConsoleWrite(_RadiansToDegrees(2*3.14159265358979)&@LF)

Func _DegreesToRadians($nDegrees)
    Local $pi = 3.14159265358979
    Return $nDegrees * $pi / 180 ; pi is equal to 180 degrees.  So remove the 180 and multiply the remaining value by pi(I did this backwards, but it doesn't matter).
EndFunc

Func _RadiansToDegrees($nRadians)
    Local $pi = 3.14159265358979
    Return $nRadians * 180 / $pi ; pi is equal to 180 degrees.  So remove the pi and multiply the remaining value by 180(I did this backwards, but it doesn't matter).
EndFuncoÝ÷ Ù¦zfÞ­× ­ç¬jwkiØÆ«z)éºÛ(^~éܶ*'J)Þ
"æ§u6§éíhºÚn¶Äáz­¦ëlj·­®((¶¸­«b¢Çè­ªâm®&§W¨­Ê(­Ø§j׬¢»%¢¬¢v®+·%{br¯z¼(®Wr¢æ«{
+)àqÞ­è¬Ê«{¦¦WèqêÞ±«­¢+Ù5Í    ½à À°ÅÕ½ÐìÅÕ½Ðì° ÄÀ½M¥¸¡}ÉÍQ½I¥¹Ì ÄÀ¤¤¤©M¥¸¡}ÉÍQ½I¥¹Ì ÄØÀ¤¤¤()Õ¹}ÉÍQ½I¥¹Ì ÀÌØí¹É̤(%1½°ÀÌØíÁ¤ô̸ÄÐÄÔäÈØÔÌÔàäÜä(%IÑÕɸÀÌØí¹Ę́ÀÌØíÁ¤¼ÄàÀ)¹Õ¹

It does give the answer as something around 19. I hope this answered your question.

- The Kandie Man ;-)


"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Share this post


Link to post
Share on other sites

@Everyone, especially monoceres

This is not so. Sin(x) does not return a number in any particular unit. It merely returns the value of the ratio of the length of the opposite side to the length of the hypotenuse of one of the non right angles in a right triangle whose angle measure is x. The angle measure is traditionally given in radians for Sine, Cosine, and Tangent functions because radians are the natural units of a circle. The only reason we use degrees is because the greeks had some fascination with using degrees instead of the more natural radians.

In the world of the unit circle, Sin() is the value of the y coordinate on the unit circle while Cos() is the value of the x coordinate on the unit circle. Tan() is equal to the slope of the angle on the unit circle.

I know you are frustrated about using radians instead of degrees, but please use the radians. They really are much more natural and much better than degrees.

Anyway, to help you, i have made this:

ConsoleWrite(Round(Cos(_DegreesToRadians(90)),2)&@LF)

ConsoleWrite(_RadiansToDegrees(2*3.14159265358979)&@LF)

Func _DegreesToRadians($nDegrees)
    Local $pi = 3.14159265358979
    Return $nDegrees * $pi / 180 ; pi is equal to 180 degrees.  So remove the 180 and multiply the remaining value by pi(I did this backwards, but it doesn't matter).
EndFunc

Func _RadiansToDegrees($nRadians)
    Local $pi = 3.14159265358979
    Return $nRadians * 180 / $pi ; pi is equal to 180 degrees.  So remove the pi and multiply the remaining value by 180(I did this backwards, but it doesn't matter).
EndFuncoÝ÷ Ù¦zfÞ­× ­ç¬jwkiØÆ«z)éºÛ(^~éܶ*'J)Þ
"æ§u6§éíhºÚn¶Äáz­¦ëlj·­®((¶¸­«b¢Çè­ªâm®&§W¨­Ê(­Ø§j׬¢»%¢¬¢v®+·%{br¯z¼(®Wr¢æ«{
+)àqÞ­è¬Ê«{¦¦WèqêÞ±«­¢+Ù5Í    ½à À°ÅÕ½ÐìÅÕ½Ðì° ÄÀ½M¥¸¡}ÉÍQ½I¥¹Ì ÄÀ¤¤¤©M¥¸¡}ÉÍQ½I¥¹Ì ÄØÀ¤¤¤()Õ¹}ÉÍQ½I¥¹Ì ÀÌØí¹É̤(1½°ÀÌØíÁ¤ô̸ÄÐÄÔäÈØÔÌÔàäÜä(IÑÕɸÀÌØí¹Ę́ÀÌØíÁ¤¼ÄàÀ)¹Õ¹

It does give the answer as something around 19. I hope this answered your question.

- The Kandie Man ;-)

Thanks for the answer. I already solved it using the function _radian() which I guess does exactly like the same as your function.

Anyways, I'm almost done with my Triangle Solver, posting it later :D


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

Thanks for the help :D

I've just posted my Triangle Solver :D


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0