Thank you for your valuable comments. Now I guess I have the algorithm to find two angles (teta and phi) of a given 3d vector. Here is the algorithm:
// First find the vector AB. (vector AB= vector B - vector A). B=(x1,y1,z1) and A=(x2,y2,z2)
// vector AB =(del_x, del_y, del_z);
del_x =...