Don't bother with the k computation, its meaningless.
j = math.asin(PQ)
However, this only works for right-angled triangles and you have to appropriate side lengths in the right places. In general this will not work and you need to use the dot product method.