-2

I'm trying to use sin on a variable and I saw you can convert it by using / (Math.PI / 180) but that seems contradictory if you want to convert it to degrees.. How do I properly convert and use sin in degree form? (On an iPhone calculator, for example it returns ~.707 from an input of 45, while this returns ~.806).

function click25() {
    if (vi === 0) {
        reactant = Math.sin(reactant / (Math.PI / 180))
    }
}
Benn
  • 55
  • 1
  • 1
  • 8

1 Answers1

2

You need to multiply the value in degree by (pi/180) to convert into the equivalent value in radians

var reactant = 45;
var vi = 0;
function click25() {
    if (vi === 0) {
        reactant = Math.sin(reactant * (Math.PI / 180))
    }
    console.log(reactant);
}

click25();
Md Johirul Islam
  • 5,042
  • 4
  • 23
  • 56
  • What about for asin, in my phone calc it returns 53 for .8 while reactant = Math.asin(reactant * (Math.PI / 180)); returns .01396 – Benn Jun 18 '18 at 18:44
  • @Benn you don't pass an angle to Asin or any of the other inverse trig functions, because they *return* an angle. – meowgoesthedog Jun 18 '18 at 19:43
  • so what is the proper usage in degrees for asin acos and atan – Benn Jun 18 '18 at 20:45