Leer en inglés

Compartir a través de


Math.Atan(Double) Método

Definición

Devuelve el ángulo cuya tangente corresponde al número especificado.

C#
public static double Atan(double d);

Parámetros

d
Double

Número que representa una tangente.

Devoluciones

Ángulo, θ, medido en radianes, de modo que -π/2 ≤ θ ≤ π/2.

o bien

NaN si d es igual a NaN, -π/2 redondeado a precisión doble (-1,5707963267949) si d es igual a NegativeInfinity, o π/2 redondeado a precisión doble (1,5707963267949) si d es igual a PositiveInfinity.

Ejemplos

En el ejemplo siguiente se muestra cómo calcular la arcotangente de un valor y mostrarla en la consola.

C#
// This example demonstrates Math.Atan()
//                           Math.Atan2()
//                           Math.Tan()
using System;

class Sample
{
    public static void Main()
    {
    double x = 1.0;
    double y = 2.0;
    double angle;
    double radians;
    double result;

// Calculate the tangent of 30 degrees.
    angle = 30;
    radians = angle * (Math.PI/180);
    result = Math.Tan(radians);
    Console.WriteLine("The tangent of 30 degrees is {0}.", result);

// Calculate the arctangent of the previous tangent.
    radians = Math.Atan(result);
    angle = radians * (180/Math.PI);
    Console.WriteLine("The previous tangent is equivalent to {0} degrees.", angle);

// Calculate the arctangent of an angle.
    String line1 = "{0}The arctangent of the angle formed by the x-axis and ";
    String line2 = "a vector to point ({0},{1}) is {2}, ";
    String line3 = "which is equivalent to {0} degrees.";

    radians = Math.Atan2(y, x);
    angle = radians * (180/Math.PI);

    Console.WriteLine(line1, Environment.NewLine);
    Console.WriteLine(line2, x, y, radians);
    Console.WriteLine(line3, angle);
    }
}
/*
This example produces the following results:

The tangent of 30 degrees is 0.577350269189626.
The previous tangent is equivalent to 30 degrees.

The arctangent of the angle formed by the x-axis and
a vector to point (1,2) is 1.10714871779409,
which is equivalent to 63.434948822922 degrees.
*/

Comentarios

Un valor devuelto positivo representa un ángulo en sentido contrario a las agujas del reloj desde el eje X; un valor devuelto negativo representa un ángulo en el sentido de las agujas del reloj.

Multiplique el valor devuelto por 180/Math.PI para convertir de radianes a grados.

Este método llama al tiempo de ejecución de C subyacente y el resultado exacto o el intervalo de entrada válido pueden diferir entre diferentes sistemas operativos o arquitecturas.

Se aplica a

Producto Versiones
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0