Let's first get the x angle out. If we know the sin(x) and cos(x), we can use the inverse tangent function atan2 to give us back our angle. Unfortunately, those values don't appear by themselves in our matrix. But, if we take a closer look at elements M[1][3]M[1][2] and M[2][3]M[2][2], we can see we do know -sin(x)*cos(y) as well as cos(x)*cos(y). Since the tangent function is the ratio of the opposite and adjacent sides of a triangle, scaling both values by the same amount (in this case cos(y)) will yield the same result. Thus,