O'Reilly logo

VB.NET Language in a Nutshell, Second Edition by Steven Roman PhD, Paul Lomax, Ron Petrusha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Atan Function

Class

System.Math

Syntax

Math.Atan(d)
d (required; Double or any valid numeric expression)

A number representing a tangent

Return Value

A Double that is the arctangent in radians of d, in the range -pi/2 to pi/2

Description

Takes the ratio of two sides of a right triangle (d) and returns the corresponding angle in radians. The ratio is the length of the side opposite the angle divided by the length of the side adjacent to the angle.

Rules at a Glance

  • If d is out of range, the function returns NaN.

  • This is a Shared member, so it can be used without creating any objects.

Example

Private Sub Main(  )

    Dim dblSideAdj As Double
    Dim dblSideOpp As Double
    Dim dblRatio As Double
    Dim dblAtangent As Double
    
    dblSideAdj = 50.25
    dblSideOpp = 75.5
    
    dblRatio = dblSideOpp / dblSideAdj
    dblAtangent = Math.Atan(dblRatio)
    'convert from radians to degrees
    dblDegrees = dblAtangent * (180 / 3.142)
    MsgBox dblDegrees & " Degrees"

End Sub

Programming Tips and Gotchas

  • To convert radians to degrees, multiply radians by 180/pi.

  • Do not confuse Atan with the cotangent. Atan is the inverse trigonometric function of Tan, whereas the cotangent is the reciprocal of the tangent.

VB.NET/VB 6 Differences

The Atan function corresponds to the VB 6 Atn intrinsic function.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required