Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

sin ,cos and tan functions !!!

Guest
Apr 05, 2013 Apr 05, 2013

hello ;

i want to create a simple calculator for only sin , tan and cos functions ,

the calculator is containing 3 buttons to calculate an input label and 3 output labels for each function

but when i wrote the following code for every button all the functions were wrong

on(release){

output_txt.text = Math.cos(input1_txt.text)

}

on(release){

output_txt.text = Math.tan(input1_txt.text)

}

on(release){

output_txt.text = Math.sin(input1_txt.text)

}

what is the right code to make these functions

TOPICS
ActionScript
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
Apr 05, 2013 Apr 05, 2013

for example

we are all knows that sin30 = .5 ,but with my calcutator it was -0.988031624092862

cos60 = .5 ,but with my calcutator it was -0.988031624092862

Translate
LEGEND ,
Apr 05, 2013 Apr 05, 2013

What were your results that make you say all the functions were wrong?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 05, 2013 Apr 05, 2013

for example

we are all knows that sin30 = .5 ,but with my calcutator it was -0.988031624092862

cos60 = .5 ,but with my calcutator it was -0.988031624092862

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 05, 2013 Apr 05, 2013

So try what I suggested:

Math.sin(30*Math.PI/180)

You must use radians with the Flash trig functions. (http://en.wikipedia.org/wiki/Radian)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 06, 2013 Apr 06, 2013
LATEST

thank U , that was helpful ...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 05, 2013 Apr 05, 2013

My guess is that you aren't converting between degrees and radians?

All the flash trig functions use radians for their input.

So if you want to change angle to radians multiply your angle by Math.Pi/180.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines