Deriving 2D Coordinate Rotation Formula I'm trying to write out the steps in code for deriving the 2D coordinate rotation formula so I can understand it.
x = radius * cos(angle)
y = radius * sin(angle)
x1 = radius * cos(angle + -rotation)
y1 = radius * sin(angle +  rotation)

So,
x1 = radius * cos(angle) * cos(rotation) – radius * sin(angle) * sin(rotation)
y1 = radius * sin(angle) * cos(rotation) + radius * cos(angle) * sin(rotation)

Therefore,
x1 = cos(rotation) * x – sin(rotation) * y
y1 = cos(rotation) * y + sin(rotation) * x

I hate to post a question just asking "Is this right?", but is this right? In particular, I'm unsure if I'm correctly representing the w (as listed in the link) in the first x1 and y1 assignment, and it's expansion. And no, this isn't homework. Thanks.
 A: Why don't you look at the rotation this way. What is the coordinates of the rotated $\hat{x}=(1,0)$ axis? From trigonometry you will find it as $X=(\cos\theta,\sin\theta)$. Now what is the coordinates of the rotated $\hat{y}=(0,1)$ axis? Similarly from trig you get $Y=(-\sin\theta,\cos\theta)$
A general vector $\vec{v}=(A,B)=A \hat{x}+B \hat{y}$ is rotated by rotating the unit vectors $V = A*(\cos\theta,\sin\theta) + B(-\sin\theta,\cos\theta)$ or re-arranged
$$ V = \begin{pmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{pmatrix} \begin{pmatrix} A \\ B \end{pmatrix} $$
So the rotation matrix is $${\rm Rot}(\theta)=\begin{pmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{pmatrix}$$
A: It's okay, just a minor detail in the initial formulation (the first four lines):
x1 = radius * cos(angle + -rotation)

Should be:
x1 = radius * cos(angle + rotation)

(No minus sign, the angle is added in both cases)
By the way, I can understand your doubts. The link you posted first names the rotation angle w and then f. They should have stuck with w or given it a significant name like you did
