javascriptmathtrigonometry

JavaScript: cotangent and arccotangent


I had searched on the internet and I could not find the method of the Math object that returns the ctg and arcctg of an angle. Is there such a method or should I just create my own function using these mathematical formulas:

enter image description here

enter image description here


Solution

  • There is not, and if you want them you will have to define them yourself. Fortunately, they are easy:

    function ctg(x) { return 1 / Math.tan(x); }
    function arcctg(x) { return Math.PI / 2 - Math.atan(x); }