I am trying to understand two equations I found in a piece of code. A two dimensional position vector which begins at an unknown point $(h, k)$ initially points at the origin, $(0, 0)$. This vector is then rotated through a given arc of $\theta$ degrees and stops at a known point $(x, y)$. Using the $x$ and $y$ coordinates of the terminal point and the angle $\theta$, the following equations are used to determine the point $(h, k)$:
$$h = \frac{x(1-\cos\theta)-y\sin\theta}{(1-\cos\theta)^2+\sin^2\theta}$$ $$k = \frac{x\sin\theta+y(1-\cos\theta)}{(1-\cos\theta)^2+\sin^2\theta}$$
Here is an example with specific values:

In the figure above, $x = 1$, $y = 5$, and $\theta = -53.1301^\circ$. Using these values and the above equations results in $(h, k) = (5.5000, 1.5000)$.
My question is how are the equations for $h$ and $k$ derived?
I understand the initial vector position and final position form the two radii of a sector. These radii and a line between the points $(0, 0)$ and $(x, y)$ form an isosceles triangle. It appears the numerators from the above equations are a matrix vector product derived from a common two dimensional rotation matrix where where $\cos\theta$ has been replaced with $(1 - \cos\theta)$. However, I do not understand why or the role of the value in the denominator. Can someone please explain how and why these equations work?
From $$ \pmatrix{x-h\\ y-k}= \pmatrix{\cos\theta & -\sin\theta \\ \sin\theta & \cos\theta} \pmatrix{-h\\ -k} $$ one finds $$ \pmatrix{x\\ y}= \pmatrix{1-\cos\theta & \sin\theta \\ -\sin\theta & 1-\cos\theta} \pmatrix{h\\ k} $$ and $$ \pmatrix{h\\ k}= \pmatrix{1-\cos\theta & \sin\theta \\ -\sin\theta & 1-\cos\theta}^{-1} \pmatrix{x\\ y}, $$ which is your formula, because: $$ \pmatrix{1-\cos\theta & \sin\theta \\ -\sin\theta & 1-\cos\theta}^{-1} ={1\over(1-\cos\theta)^2+\sin^2\theta} \pmatrix{1-\cos\theta & -\sin\theta \\ \sin\theta & 1-\cos\theta}. $$