AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

sin, cos, tan problem.

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
vlcek



Joined: 19 Feb 2007
Posts: 338
Location: Czech Republic

PostPosted: Thu Apr 30, 2009 4:28 pm    Post subject: sin, cos, tan problem. Reply with quote

Hi, I need this:
gui,add,text,sinus
gui,add,edit,vsinnum
gui,add,edit,gok,ok
gui,show,sinus
return
ok:
gui,submit,nohide
sin(sinnum)
msgbox, Result is %sinnum%
This return normaly user writen number, why not sinus result?
_________________
Thanks.
Back to top
View user's profile Send private message Visit poster's website
tonne



Joined: 06 Jun 2006
Posts: 1651
Location: Denmark

PostPosted: Thu Apr 30, 2009 6:04 pm    Post subject: Reply with quote

Code:
msgbox, % "Result is " . sin(sinnum) ; ?

_________________
RegEx Powered Dynamic Hotstrings
COM
AutoHotkey 2
Back to top
View user's profile Send private message
vlcek



Joined: 19 Feb 2007
Posts: 338
Location: Czech Republic

PostPosted: Fri May 01, 2009 7:53 am    Post subject: Reply with quote

But next problem.
Sinus 30 is 0,5, but my calculator show 0,983... Why?
_________________
Thanks.
Back to top
View user's profile Send private message Visit poster's website
[VxE]



Joined: 07 Oct 2006
Posts: 3254
Location: Simi Valley, CA

PostPosted: Fri May 01, 2009 8:02 am    Post subject: Reply with quote

vlcek wrote:
But next problem.
Sinus 30 is 0,5, but my calculator show 0,983... Why?

The Manual wrote:
Sin(Number) | Cos(Number) | Tan(Number) : Returns the trigonometric sine|cosine|tangent of Number. Number must be expressed in radians.

Code:
DegToRad(deg)
{
   static pi := 3.14159265358979323846
   return deg * pi / 180
}


[edit:] quick fix
_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!


Last edited by [VxE] on Fri May 01, 2009 8:08 am; edited 1 time in total
Back to top
View user's profile Send private message
Guest






PostPosted: Fri May 01, 2009 8:05 am    Post subject: Reply with quote

Incorrect
Back to top
tonne



Joined: 06 Jun 2006
Posts: 1651
Location: Denmark

PostPosted: Fri May 01, 2009 8:08 am    Post subject: Reply with quote

Code:
DegToRad(deg)
{
   static pi := 3.14159265358979323846
   return deg * pi / 180
}

_________________
RegEx Powered Dynamic Hotstrings
COM
AutoHotkey 2
Back to top
View user's profile Send private message
vlcek



Joined: 19 Feb 2007
Posts: 338
Location: Czech Republic

PostPosted: Fri May 01, 2009 9:07 am    Post subject: Reply with quote

tonne wrote:
Code:
DegToRad(deg)
{
   static pi := 3.14159265358979323846
   return deg * pi / 180
}

Result of sin 30 is with your code 0,983032.
I use your code and msgbox, % "Result is " . sin(sinnum)
_________________
Thanks.
Back to top
View user's profile Send private message Visit poster's website
tonne



Joined: 06 Jun 2006
Posts: 1651
Location: Denmark

PostPosted: Fri May 01, 2009 9:39 am    Post subject: Reply with quote

I get 0.5 with:
Code:
msgbox % sin(degtorad(30))   

DegToRad(deg)
{
   static pi := 3.14159265358979323846
   return deg * pi / 180
}

_________________
RegEx Powered Dynamic Hotstrings
COM
AutoHotkey 2
Back to top
View user's profile Send private message
vlcek



Joined: 19 Feb 2007
Posts: 338
Location: Czech Republic

PostPosted: Fri May 01, 2009 12:28 pm    Post subject: Reply with quote

Now, I have problem with Asin(number.
When I want asin(0.5), the result is 30, but my calculator show 0.523... Why?
_________________
Thanks.
Back to top
View user's profile Send private message Visit poster's website
tonne



Joined: 06 Jun 2006
Posts: 1651
Location: Denmark

PostPosted: Fri May 01, 2009 1:55 pm    Post subject: Reply with quote

From the help file
Quote:
Note: To convert a radians value to degrees, multiply it by 180/pi (approximately 57.29578). To convert a degrees value to radians, multiply it by pi/180 (approximately 0.01745329252). The value of pi (approximately 3.141592653589793) is 4 times the arctangent of 1.


Code:
msgbox % RadToDeg(Asin(0.5))

RadToDeg(rad)
{
  static pi := 3.14159265358979323846
  return rad * 180 / pi
}

_________________
RegEx Powered Dynamic Hotstrings
COM
AutoHotkey 2
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group