Search code examples
javascriptmathtrigonometryangle

get degrees from ratio via tan


I want to get an angle in degrees of a triangle, in JS.

How can I get out the degrees of the angle with Tangent after calculating opposite / adjacent?

Formula for TAN


Solution

  • degrees = Math.atan(a/b) * 180 / Math.PI;
    

    Be certain to validate b... bad things may happen if it is 0.

    References: Math.atan, Math.PI