Do you know how to work out a vector normal to the plane containing your three points?

Say it was <3,4,12>

You can use the first two components to work out the rotation in the XY plane.

Then take the length of the projection onto the XY plane, (5 in my example) and use this and the third component to get your other angle.