I came across a question from another forum -
find the $x$ in the following diagram:

I managed to deduce an equation from the following diagram:

which is: $\dfrac{\sqrt{5}(\cos \theta - \sin \theta)}{3\sqrt{2}}=\tan \theta$
and I know the answer (from WolframAlpha) is: $\cos \theta= \dfrac{3}{\sqrt{10}}$
but I'm not able to deduce the answer myself, any ideas?
By the way, $x=2\sqrt{5}$, which can be easily deduced by:
$\dfrac{3\sqrt{2}}{x}=\cos\theta$
I also tried to solve the original question geometrically:

Somehow, I managed to figure out that $y=3$ in the above diagram, but I can't prove it either.

Defining $c := \cos\theta$ and $s := \sin\theta$, we can write $$c^2\sqrt{5} = s\left(3 \sqrt{2} + c\sqrt{5}\right) \tag{1}$$ Squaring, re-writing $s^2 = 1-c^2$, and re-arranging, $$10 c^4 + 6 c^3 \sqrt{10} + 13 c^2 - 6c \sqrt{10} - 18 = 0 \tag{2}$$
At this point, if we had the presence of mind to identify $10$ as $\sqrt{10}^2$ and $13$ as $-27 + 4\sqrt{10}^2$, then (defining $r:=\sqrt{10}$) we could gather terms and factor
$$\begin{align} 0 &= r^2 c^4 +\left(-3r + 9 r\right)c^3 + (-27+4r^2)c^2 +(-12r+ 6r)c - 18 \\[4pt] &= \left(r^2 c^4 - 3rc^3\right) + \left(9 rc^3 -27c^2\right)+\left(4r^2c^2 -12rc\right)+ \left(6rc - 18\right)\\[4pt] &= \left(r c - 3 \right) \left( rc^3 + 9 c^2 +4 r c + 6 \right) \tag{3} \end{align}$$ (That is, we have factored over $\mathbb{Q}\left[\sqrt{10}\right]$.) The first factor yields the target root, $\cos\theta = 3/\sqrt{10}$. (Note that the second factor obviously has no positive solutions.)
Without such intuition, but with a suspicion that the $\sqrt{10}$s were impeding progress to a reasonably-nice solution, we could write $(2)$ as $$10 c^4 + 13 c^2-18 = 6c\sqrt{10}\left(1-c^2\right) \tag{4}$$ Now, squaring will eliminate the pesky $\sqrt{10}$, and we have $$100 c^8 - 100 c^6 + 529 c^4 - 828 c^2 + 324 = 0 \tag{5}$$ From here, old-fashioned factoring gives
$$\left(10 c^2 - 9\right) (10 c^6 - c^4 + 52c^2 -36 ) = 0\tag{6}$$
Again, the first factor gives the target root, $\cos\theta=3/\sqrt{10}$ (as well as a newly-introduced extraneous root, $\cos\theta=-3/\sqrt{10}$). It's not clear that the second factor has no valid roots; indeed, Mathematica gives the positive solution $\cos\theta = 0.80501\ldots$ (amid otherwise negative or non-real candidates), but we can check that it doesn't satisfy $(1)$.