Let's break this down:
Let's say that
In the triangle where this is true, we see that
We can draw a triangle where
Through the Pythagorean Theorem we see that the other leg is
What we want to find is
That is, we just want cosine of theta in this triangle.
Cosine is "adjacent" over hypotenuse, so: