| La référence javascript : Objets, méthodes, propriétés |
|
| Méthode : Math.tan() Retourne la tangente d'un nombre réel. Compatible : Syntaxe Float Math.tan(Float x) Description Retourne la tangente du nombre réel passé en paramètre (unité : radians). Rappel : tan(x) est indéfini pour tout x = Pi/2 + 2*k*Pi, k entier relatif. En JavaScript, on obtiendra des valeurs excessivement grandes. Rappel : tan(x) = sin(x)/cos(x) Exemple Utilisation Code source <SCRIPT TYPE="text/javascript"> document.write('tan(0) = ' + Math.tan(0) + '<BR>n'); document.write('tan(Pi/2) = ' + Math.tan(Math.PI/2) + '<BR>n'); document.write('tan(Pi) = ' + Math.round(Math.tan(Math.PI)) + '<BR>n'); </SCRIPT> Résultat Explication Affiche la valeur de tan(0), tan(Pi/2) (indéfini => très grand en JavaScript), et tan(Pi). Un arrondi est effectué à l'aide de Math.round(), sinon on obtient une valeur très proche de 0 mais différente de 0. Page en rapport Tutoriel : les fonctions mathématiques en javascript |
| Reproduction ou diffusion interdite sans autorisation de Tout JavaScript.com |