Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i use inversed tan in javascript?

Tags:

javascript

I need to calculate an angle of a triangle by using the tan^-1 function. On my calculator I can do this:

tan^-1(3/4) // 3 and 4 are triangle side lengths

And it outputs 36 degrees. What is the alternative to this function in JavaScript? I tried Math.tan(3/4), Math.atan(3/4) and all of the other tan functions I saw in the list, but none of them outputs the result in degrees I need (36). Thank you.

like image 256
Askerman Avatar asked Sep 29 '15 11:09

Askerman


People also ask

How do you use tan inverse in JavaScript?

In JavaScript, Math is a built-in object that contains different methods and properties used to perform mathematical operations. It contains an atan() function, which is used to compute a specified number's arc tangent. This is also known as the inverse tangent of a number.

How do you do tan inverse?

Inverse Tan Formula In a right-angled triangle, the tangent of an angle (θ) is the ratio of its opposite side to the adjacent side. i.e., tan θ = (opposite side) / (adjacent side). Then by the definition of inverse tan, the inverse tan formula is, θ = tan-1[ (opposite side) / (adjacent side) ] .

What does atan2 do in JavaScript?

atan2() function returns the angle in the plane (in radians) between the positive x-axis and the ray from (0, 0) to the point (x, y), for Math.


1 Answers

There is no build in function for that, since 1 radian = 180/pi degrees you can do the following using Math.atan() and Math.PI

var degree = Math.atan(3 / 4) * (180 / Math.PI);

document.write(degree);
like image 193
Pranav C Balan Avatar answered Sep 28 '22 09:09

Pranav C Balan