Compute angle $\gamma$ between a line and a plane if the line forms angles $\alpha$ and $\beta$ with two perpendicular lines lying in the plane. Exercise

Compute angle $\gamma$ between a line and a plane if the line forms angles $\alpha$ and $\beta$ with two perpendicular lines lying in the plane.


Attempt
Let lines $a$ and $b$ be perpendicular on plane $M$, intersecting at point $O$, and line $c$ intersecting $M$ at point $P$.
Mark a point $A$ on $a$, and $B$ on $b$.
Draw line $c'_a$ (and mark a point $C'_a$ on it) through $A$ parallel to $c$, and $c'_b$ (and mark a point $C'_b$ on it) through $B$ parallel to $c$.
Let $\angle ac'_a = \alpha$, and $\angle bc'_b = \beta$.
Draw line $c''$ through O parallel to $c$ (and consequently $c'_a$ and $c'_b$).
$\angle ac'' = \alpha$, and $\angle bc'' = \beta$.
Mark a point P on $c''$, and drop perpendiculars from it onto $a$ and $b$ intersecting at $A'$ and $B'$ respectively.
Let $OP = 1$.
$A'O = \cos \alpha$, $A'P = \sin \alpha$, $B'O = \cos \beta$, $B'P = \sin \beta$.
Drop a perpendicular from $P$ onto $M$ at point $Q$.
Here's where I think my logic gets faulty (therefore rendering this proof useless)...
$OQ = \sqrt{\cos^2 \alpha + \cos^2 \beta}$ \\ This might be incorrect because I think that $\angle A'OP \neq \angle A'OQ$ and $\angle B'OP \neq \angle B'OQ$.
$c = \cos \gamma$
$\gamma = \arccos(\sqrt{\cos^2 \alpha + \cos^2 \beta})$

Was I on the right track, or did I walk into a dead end?
If I was indeed on the right track, where do I go from here?
 A: I couldn't read all of your attempt. Let $a$ and $b$ be the perpendicular lines lying in the plane $M$ and intersecting at the point $O$ and let $c$ be the line that is transverse to $M$ and whose angle with $M$ you are looking for. Simply, first draw a line $c'$ parallel to $c$ through point $O$. Pick an arbitrary point $C$ on $c'$. Then in the plane formed by the line $a$ and the line $c' \equiv OC$ draw the line from $C$ perpendicular to line $a$ and denote its intersection point with $a$ by $A$. Analogously, in the plane formed by the line $b$ and the line $OC$ draw the line from $C$ perpendicular to line $b$ and denote its intersection point with $b$ by $B$. Let he orthogonal projection of point $D$ onto the plane $M$ be $D$. Then the angle you are looking for is $\gamma = \angle \, COD$. 
You have now a pyramid $OADBC$ with an apex $C$ and base $OADB$. Since $CD$ is perpendicular to the whole plane $M$, it is perpendicular to $a$ and $b$. However, also the lines $AC$ and $BC$ are by construction orthogonal to $a \equiv OA$ and $b \equiv OB$ respectively. Since $OA$ is orthogonal to both $CD$ and $AC$ it is perpendicular to the whole plane $CAD$ and is therefore perpendicular to $DA$. Absolutely analogous argument implies that $DB$ is perpendicular to $OB$. Therefore, the base quad $OADB$ has three angles that measure $90^{\circ}$ so it is a rectangle. Since triangle $AOC$ is right angled with right angle at $A$ and $\angle \, AOC = \alpha$, 
$$OA = OC \, \cos{\alpha}$$ 
Analogously, 
$$OB = OC \, \cos{\beta}$$
But since $OADB$ is a rectangle, $OB=AD = OC \, \cos{beta}$ and triangle $OAD$ is right angled with right angle at vertex $A$. Apply Pytagoras' theorem and get
$$OD^2 = OA^2 + AD^2 =  OC^2 \, \cos^2{\alpha} +  OC^2 \, \cos^2{\beta}$$ 
Triangle $ODC$ is also right angled and $\gamma = \angle \, DOC$ so 
$$\cos{\gamma} = \frac{OD}{OC} = \frac{OC \, \sqrt{\cos^2{\alpha} + \cos^2{\beta}}}{OC} =  \sqrt{\cos^2{\alpha} + \cos^2{\beta}}$$      
A: Hint 1: the sum of the squares of the cosines of the angles between a vector and each of the coordinate axes is $1$. See Direction Cosine.
Hint 2: consider the two perpendicular vectors in the plane and the normal to the plane to be an orthonormal basis for $\mathbb{R}^3$.

Answer Ignoring Hints
Let $OQ$ and $OR$ lie on the perpendicular lines in the plane, and $OS$ be perpendicular to the plane. Let $OP$ lie on the line in the question. Then $\angle POS$ is the complement of the angle between the plane and the line in the question, that is, $\pi/2-\gamma$.

$\cos(\alpha)=\cos(\angle POQ)=\frac{|OQ|}{|OP|}$
$\cos(\beta)=\cos(\angle POR)=\frac{|OR|}{|OP|}$
$\cos(\pi/2-\gamma)=\cos(\angle POS)=\frac{|OS|}{|OP|}$  
Since $|OP|^2=|OQ|^2+|OR|^2+|OS|^2$, we have
$$
\cos^2(\alpha)+\cos^2(\beta)+\cos^2(\pi/2-\gamma)=1\tag{1}
$$
Since $\cos(\pi/2-\gamma)=\sin\left(\gamma\right)$, $(1)$ implies
$$
\cos^2(\alpha)+\cos^2(\beta)+\sin^2(\gamma)=1\tag{2}
$$
This means that
$$
\cos^2(\alpha)+\cos^2(\beta)=\cos^2(\gamma)\tag{3}
$$

As for where you go from here, that depends on what you want to do with the answer you've gotten.
