当前位置: 首页>>代码示例>>C#>>正文


C# Math.Tan方法代码示例

本文整理汇总了C#中System.Math.Tan方法的典型用法代码示例。如果您正苦于以下问题:C# Math.Tan方法的具体用法?C# Math.Tan怎么用?C# Math.Tan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Math的用法示例。


在下文中一共展示了Math.Tan方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

// 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);
    }
}
开发者ID:.NET开发者,项目名称:System,代码行数:39,代码来源:Math.Tan

输出:

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.

示例2: Math.Tan()

//引入命名空间
using System; 
 
public class Trigonometry {    
  public static void Main() {    
    Double theta;
     
    for(theta = 0.1; theta <= 1.0; theta = theta + 0.1) { 
      Console.WriteLine("Sine of " + theta + "  is " + 
                        Math.Sin(theta)); 
      Console.WriteLine("Cosine of " + theta + "  is " + 
                        Math.Cos(theta)); 
      Console.WriteLine("Tangent of " + theta + "  is " + 
                        Math.Tan(theta)); 
      Console.WriteLine(); 
    } 
 
  }    
}
开发者ID:C#程序员,项目名称:System,代码行数:19,代码来源:Math.Tan


注:本文中的System.Math.Tan方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。