The converter is so fast because it uses
exclusively
8-bit values. Theta (the angle) runs
0-255 around the
circle, giving a resolution of about 1.4
degrees. R can
go out to about 160, and X and Y to +127/-128
signed.
Better angular resolution could be had with the
same
algorithm up to 1/1024 circle at the cost of
some extra
cycles in the conversion process and a longer
trig table.
Three tables are used totaling a bit under 700
bytes.
The secret to this algorithm is logarithms
(now there's
a word I bet you never thought you'd read in this list).
The source is fully documented with theory and I have
placed it in the public domain. Let me know if you
would like the BASIC program to generate the log, exp,
and trig tables for different maximum values. Close-in
accuracy can be improved by sacrificing maximum distance,
and vice-versa. The calculations aren't exact but are
quite good for game type display work.
(BTW you can also use the log and exp tables for general
purpose scaling multiplication and division. They are
surprisingly accurate, with few errors greater than 1 out
to results of 45 or so, and errors that increase gradually
as the outer limits are reached.)