On this thread, Bernard kindly gave me the formula
$$\sum_{k=0}^R \cos k \theta = \frac{\sin \frac{(R+1)\theta}{2}}{\sin \frac{\theta}{2}} \cos \frac{R \theta}{2}$$
He describes the formula as well-known. Does it have a name, so I can find a few pages relating to it?