## A simple way to pre-compute sin/cos tables

This is a kind of an old school trick, rarely useful nowadays, but it’s nonetheless interesting due to its simplicity and elegancy.
The main idea is about filling a table with pre-computed values of $\sin a$ and $\cos a$ within a certain interval, using infinitesimal rotations.We start to work in two dimensions with a clockwise rotation matrix: $R = \begin{pmatrix}\cos\alpha\ && -\sin\alpha\ \\ \sin\alpha\ && \cos\alpha\ \end{pmatrix}$

For very small rotation angles $\alpha\ \to 0$ thus we can expand our rotation matrix elements with a Taylor series around zero.
Ignoring all the non linear terms we get something like this: $R' = \begin{pmatrix}1 && -\alpha\ \\ \alpha\ && 1 \end{pmatrix}$

Now we can generate our values on an interval $\left [ s, t \right )$ recursively applying $R'$ on a unit vector $\hat{u} = ( \cos s, \sin s )$. $\hat{u'} = \hat{u}R'$ $=( u_x, u_y ) \begin{pmatrix}1 && -\alpha\ \\ \alpha\ && 1 \end{pmatrix}$ $= \begin{cases} u'_x = u_x + u_y\alpha\ \\ u'_y = -u_x\alpha\ + u_y \end{cases}$

Supposing that we don’t have at hand any code or library that can compute $\hat{u}$ for an arbitrary value of $s$, we start with $s = 0 \to \hat{u} = ( 1, 0 )$. Read the rest of this entry »

Advertisements

## Yes, yet another blog

### Hello World!

I thought about having a blog or some kind of personal web site since the first time I came to use The Almighty Internet.So please, bear with me if at the beginning I’m going to be a tad slow at filling it with new ramblings.
Thank you, and enjoy.