Sine and cosine on NXT
update 23/12/06 : New Version 1.1 (accuracy now less than ±0.002 !!!)
With the help of CORDIC algorithm we also can produce the sine and the cosine functions. The absolute error always is smaller than ±0.002. Note the particularity that CORDIC computes the sine and the cosine at the same time !
f(x)=sin(angle) ; g(x)=cos(angle)
Since NXT can deal with integer values only , angles are entered in deci_degrees. The result is milli.
Example: sin(600deci°) = 860milli=0.860
Computing speed on NXT: 14ms. (Not that famous due to missing bit shift operations in the NI function palette):
Suggestion to NI: please add bit shift-operations !!!!!!
The NXT toolkit allows creating 3d party NXT blocks. This is a bit tricky, but once you are familiar with the procedure, you'll create anything you want. Here the implementation into a NXT G-program. (You need to install the Dynamic Block Update from http://mindstorms.lego.com/support/updates/ )
|DOWNLOAD SIN COS BLOCK|