Ok, I think I'm on the right way now.
Let's call

the angle between x and y, and

the one between y and z.
x and z join the "external" corners with the observer, and y joins the one which is farthest from the obs. Thus, y is between the two and is shared between

and

.

and

are the angles opposite to x and z, respectively. Since we're working on a half-square, their sum is

.
These are the calculations to be done, exploting theorems of sines and cosines:
(am I correct until here?)
So the the computer's mission is to find an x value such as the calculated

is near enough to the given

. This can be done in a way I'll investigate soon
Thanks mr fantastic to pointing me to the right direction!!!