--- title: Math.atan() slug: Web/JavaScript/Reference/Global_Objects/Math/atan translation_of: Web/JavaScript/Reference/Global_Objects/Math/atan ---
{{JSRef}}

La funzione Math.atan() restituisce l'arcotangente (in radianti) di un numero, definita come

Math.atan(x)=arctan(x)= l'unica y[-π2;π2]tale chetan(y)=x\mathtt{\operatorname{Math.atan}(x)} = \arctan(x) = \text{ the unique } \; y \in \left[-\frac{\pi}{2}; \frac{\pi}{2}\right] \, \text{such that} \; \tan(y) = x

Sintassi

Math.atan(x)

Parametri

x
Un numero.

Valore di ritorno

L'arcotangente (in radianti) del numero dato x.

Descrizione

Il metodo Math.atan() ritorna un valore numerico compreso tra -π2-\frac{\pi}{2} e π2\frac{\pi}{2} radianti.

Poiché atan() è un membro statico di Math, è da usarsi sempre nella forma Math.atan(), piuttosto che come un metodo di un oggetto Math creato (Math non è il costruttore di una classe).

Esempî

Using Math.atan()

Math.atan(1);   // 0.7853981633974483
Math.atan(0);   // 0
Math.atan(-0);  // -0

Math.atan(Infinity);   //  1.5707963267948966
Math.atan(-Infinity);  // -1.5707963267948966

/*
L'angolo che la retta su cui giace il segmento [(0,0);(x,y)]
forma con l'asse x di un sistema a coordinate cartesiane
*/
Math.atan(y / x);

Note that you may want to avoid using ±Infinity for stylistic reasons. In this case, {{jsxref("Math.atan2()")}} with 0 as the second argument may be a better solution.

Specifiche

Specifica Status Commento
{{SpecName('ES1')}} {{Spec2('ES1')}} Definizione iniziale. Implementata in JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.4', 'Math.atan')}} {{Spec2('ES5.1')}}  
{{SpecName('ES6', '#sec-math.atan', 'Math.atan')}} {{Spec2('ES6')}}  
{{SpecName('ESDraft', '#sec-math.atan', 'Math.atan')}} {{Spec2('ESDraft')}}  

Compatibilità con i browser

{{Compat("javascript.builtins.Math.atan")}}

Vedere anche