Updated 2012-05-14 09:50:16 by RLE

Purpose: Explain the math function atan.

The call,
    [expr { atan( $x ) }]

returns the arcus tangent (inverse tangent) of the number, $x. The resulting angle is measured in radians.

The most common reason for computing an arctangent is to determine the angle from the positive x-axis to a vector in the plane, but for that purpose it is much better to use atan2. Consider the point (x,y) = (-1,1). The angle to this point is 3/4*pi and the tangent for this vector is -1, but
 % expr atan(-1)
 -0.785398

i.e., the angle -1/4*pi, on account on the fact that this angle also has tangent -1. atan2 can distinguish the two:
 % expr atan2(1,-1)
 2.35619
 % expr atan2(-1,1)
 -0.785398

atan provides a handy way to ask Tcl for the value of pi: See pi

atan is also available in Tclx.