Math.Atan2 Method

Returns the angle that corresponds to the quotient of two values.
...Math.Atan2(sine_factor, cosine_factor )

Prerequisites

None

Parameters

sine_factor

A required expression, which when divided by cosine_factor, is equal to the tangent of the angle.

cosine_factor

A required expression, which when divided into sine_factor, is equal to the tangent of the angle.

Remarks

Returns the angle, in radians, that corresponds to the tangent value computed from sine_factor/cosine_factor and using the signs of sine_factor and cosine_factor to uniquely determine the quadrant of the angle. As a simplified example, if A is the sine of an angle C and B is the cosine of the angle, then this arc tangent function returns C when given the values A and B. Unlike the Math.Atan method, this method can return the full range of angles from +π to –π. In addition, it does not suffer from requiring infinite valued parameters in order to represent any angular value. So, Math.Atan2 should be used whenever possible instead of Math.Atan. To convert radians to degrees, multiply the radians times 180/π.

Examples

Dim angle As Single
angle = Math.Atan2(1,0) ' Sets angle to Pi/2
angle = Math.Atan2(.5,-.5) ' Sets angle to 3*Pi/4
angle = Math.Atan2(-.707,.707) ' Sets angle to -Pi/4

See Also

Math Class