Draw a line between the top of the left triangle and the top of the right triangle.
The length (d) of this line is √(a2+b2), and the angle (α) at the top of the left triangle is arctan(b/a).
The angle between this new line and the vertical is (α+θ).
Sliding this line down by the height of the right triangle forms a triangle with the left and lower lines, without changing the angle or the length d.
Therefore arcsin(c/d) = (α+θ), or θ = arcsin(c/d)- α
Or written out in full:
θ = arcsin(c/√(a2+b2))- arctan(b/a)