V8/usr/man/man9/cos.9
.TH COS 9.3
.SH NAME
cos, sin, atan2, sqrt, norm \- integer math functions
.SH SYNOPSIS
.B int cos(d)
.B int d;
.PP
.B int sin(d)
.B int d;
.PP
.B int atan2(x, y)
.B int x, y;
.PP
.B int norm(x, y, z)
.B int x, y, z;
.PP
.B int sqrt(x)
.B long x;
.PP
.SH DESCRIPTION
.I Cos
and
.I Sin
return scaled integer approximations to the trigonometric functions.
The argument values are in degrees.
The return values are scaled so that
.IR cos (0)=1024 .
Therefore, to calculate, for example, the mathematical expression
.IR x = x0*cos ( d ),
the multiplication must be scaled:
.IP
x=muldiv(x0, cos(d), 1024).
.PP
.I Atan2
returns the approximate arc-tangent of
.IR y / x .
The return value is in integral degrees.
The approximation is poor; the error may be as large as two degrees.
.PP
.I Sqrt
returns the 16-bit signed integer closest to the
square root of its 32-bit signed argument.
.PP
.I Norm
returns the Pythagorean length of the three-vector
.RI ( x ,
.IR y ,
.IR z ).
.SH DIAGNOSTICS
.IR Atan2 (0,\ 0)
and
.IR sqrt (0)
return 0.
.IR Norm
does not protect against overflow.