当前位置: 首页>>代码示例>>VB.NET>>正文


VB.NET Math.Atan2方法代码示例

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


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

示例1: Sample

' This example demonstrates Math.Atan()
'                           Math.Atan2()
'                           Math.Tan()
Class Sample
   Public Shared Sub Main()
      Dim x As Double = 1.0
      Dim y As Double = 2.0
      Dim angle As Double
      Dim radians As Double
      Dim result As Double
      
      ' 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.
      Dim line1 As [String] = "{0}The arctangent of the angle formed by the x-axis and "
      Dim line2 As [String] = "a vector to point ({0},{1}) is {2}, "
      Dim line3 As [String] = "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)
   End Sub
End Class
开发者ID:VB.NET开发者,项目名称:System,代码行数:35,代码来源:Math.Atan2

输出:

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: Tester

Public Class Tester
    Public Shared Sub Main
        Dim magnitude As Single
        Dim radians As Single

        magnitude = CSng(Math.Sqrt(100 ^ 2 + 120 ^ 2))
        radians = CSng(Math.Atan2(100, 123))


        Console.WriteLine(magnitude)
        Console.WriteLine(radians)
        
    End Sub

End Class
开发者ID:VB程序员,项目名称:System,代码行数:15,代码来源:Math.Atan2


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