function [fx_d_o] = make_fx_d_o(c,o,p,k,X0,Y0,Z0,X,Y,Z)
fx_d_o=((Y - Y0)*(-sin(k)*sin(o) + sin(p)*cos(k)*cos(o)) + (Z - Z0)*(sin(k)*cos(o) + sin(o)*sin(p)*cos(k)))/((X - X0)*sin(p) - (Y - Y0)*sin(o)*cos(p) + (Z - Z0)*cos(o)*cos(p)) + ((Y - Y0)*cos(o)*cos(p) + (Z - Z0)*sin(o)*cos(p))*(-c*(X - X0)*cos(k)*cos(p) + (Y - Y0)*(sin(k)*cos(o) + sin(o)*sin(p)*cos(k)) + (Z - Z0)*(sin(k)*sin(o) - sin(p)*cos(k)*cos(o)))/((X - X0)*sin(p) - (Y - Y0)*sin(o)*cos(p) + (Z - Z0)*cos(o)*cos(p))**2;
end
function [fy_d_o] = make_fy_d_o(c,o,p,k,X0,Y0,Z0,X,Y,Z)
fy_d_o=((Y - Y0)*(-sin(k)*sin(p)*cos(o) - sin(o)*cos(k)) + (Z - Z0)*(-sin(k)*sin(o)*sin(p) + cos(k)*cos(o)))/((X - X0)*sin(p) - (Y - Y0)*sin(o)*cos(p) + (Z - Z0)*cos(o)*cos(p)) + ((Y - Y0)*cos(o)*cos(p) + (Z - Z0)*sin(o)*cos(p))*(c*(X - X0)*sin(k)*cos(p) + (Y - Y0)*(-sin(k)*sin(o)*sin(p) + cos(k)*cos(o)) + (Z - Z0)*(sin(k)*sin(p)*cos(o) + sin(o)*cos(k)))/((X - X0)*sin(p) - (Y - Y0)*sin(o)*cos(p) + (Z - Z0)*cos(o)*cos(p))**2;
end
function [fx_d_p] = make_fx_d_p(c,o,p,k,X0,Y0,Z0,X,Y,Z)
fx_d_p=(c*(X - X0)*sin(p)*cos(k) + (Y - Y0)*sin(o)*cos(k)*cos(p) - (Z - Z0)*cos(k)*cos(o)*cos(p))/((X - X0)*sin(p) - (Y - Y0)*sin(o)*cos(p) + (Z - Z0)*cos(o)*cos(p)) + (-(X - X0)*cos(p) - (Y - Y0)*sin(o)*sin(p) + (Z - Z0)*sin(p)*cos(o))*(-c*(X - X0)*cos(k)*cos(p) + (Y - Y0)*(sin(k)*cos(o) + sin(o)*sin(p)*cos(k)) + (Z - Z0)*(sin(k)*sin(o) - sin(p)*cos(k)*cos(o)))/((X - X0)*sin(p) - (Y - Y0)*sin(o)*cos(p) + (Z - Z0)*cos(o)*cos(p))**2;
end
function [fy_d_p] = make_fy_d_p(c,o,p,k,X0,Y0,Z0,X,Y,Z)
fy_d_p=(-c*(X - X0)*sin(k)*sin(p) - (Y - Y0)*sin(k)*sin(o)*cos(p) + (Z - Z0)*sin(k)*cos(o)*cos(p))/((X - X0)*sin(p) - (Y - Y0)*sin(o)*cos(p) + (Z - Z0)*cos(o)*cos(p)) + (-(X - X0)*cos(p) - (Y - Y0)*sin(o)*sin(p) + (Z - Z0)*sin(p)*cos(o))*(c*(X - X0)*sin(k)*cos(p) + (Y - Y0)*(-sin(k)*sin(o)*sin(p) + cos(k)*cos(o)) + (Z - Z0)*(sin(k)*sin(p)*cos(o) + sin(o)*cos(k)))/((X - X0)*sin(p) - (Y - Y0)*sin(o)*cos(p) + (Z - Z0)*cos(o)*cos(p))**2;
end
function [fx_d_k] = make_fx_d_k(c,o,p,k,X0,Y0,Z0,X,Y,Z)
fx_d_k=(c*(X - X0)*sin(k)*cos(p) + (Y - Y0)*(-sin(k)*sin(o)*sin(p) + cos(k)*cos(o)) + (Z - Z0)*(sin(k)*sin(p)*cos(o) + sin(o)*cos(k)))/((X - X0)*sin(p) - (Y - Y0)*sin(o)*cos(p) + (Z - Z0)*cos(o)*cos(p));
end
function [fy_d_k] = make_fy_d_k(c,o,p,k,X0,Y0,Z0,X,Y,Z)
fy_d_k=(c*(X - X0)*cos(k)*cos(p) + (Y - Y0)*(-sin(k)*cos(o) - sin(o)*sin(p)*cos(k)) + (Z - Z0)*(-sin(k)*sin(o) + sin(p)*cos(k)*cos(o)))/((X - X0)*sin(p) - (Y - Y0)*sin(o)*cos(p) + (Z - Z0)*cos(o)*cos(p));
end
function [fx_d_X0] = make_fx_d_X0(c,o,p,k,X0,Y0,Z0,X,Y,Z)
fx_d_X0=c*cos(k)*cos(p)/((X - X0)*sin(p) - (Y - Y0)*sin(o)*cos(p) + (Z - Z0)*cos(o)*cos(p)) + (-c*(X - X0)*cos(k)*cos(p) + (Y - Y0)*(sin(k)*cos(o) + sin(o)*sin(p)*cos(k)) + (Z - Z0)*(sin(k)*sin(o) - sin(p)*cos(k)*cos(o)))*sin(p)/((X - X0)*sin(p) - (Y - Y0)*sin(o)*cos(p) + (Z - Z0)*cos(o)*cos(p))**2;
end
function [fy_d_X0] = make_fy_d_X0(c,o,p,k,X0,Y0,Z0,X,Y,Z)
fy_d_X0=-c*sin(k)*cos(p)/((X - X0)*sin(p) - (Y - Y0)*sin(o)*cos(p) + (Z - Z0)*cos(o)*cos(p)) + (c*(X - X0)*sin(k)*cos(p) + (Y - Y0)*(-sin(k)*sin(o)*sin(p) + cos(k)*cos(o)) + (Z - Z0)*(sin(k)*sin(p)*cos(o) + sin(o)*cos(k)))*sin(p)/((X - X0)*sin(p) - (Y - Y0)*sin(o)*cos(p) + (Z - Z0)*cos(o)*cos(p))**2;
end
function [fx_d_Y0] = make_fx_d_Y0(c,o,p,k,X0,Y0,Z0,X,Y,Z)
fx_d_Y0=(-sin(k)*cos(o) - sin(o)*sin(p)*cos(k))/((X - X0)*sin(p) - (Y - Y0)*sin(o)*cos(p) + (Z - Z0)*cos(o)*cos(p)) - (-c*(X - X0)*cos(k)*cos(p) + (Y - Y0)*(sin(k)*cos(o) + sin(o)*sin(p)*cos(k)) + (Z - Z0)*(sin(k)*sin(o) - sin(p)*cos(k)*cos(o)))*sin(o)*cos(p)/((X - X0)*sin(p) - (Y - Y0)*sin(o)*cos(p) + (Z - Z0)*cos(o)*cos(p))**2;
end
function [fy_d_Y0] = make_fy_d_Y0(c,o,p,k,X0,Y0,Z0,X,Y,Z)
fy_d_Y0=(sin(k)*sin(o)*sin(p) - cos(k)*cos(o))/((X - X0)*sin(p) - (Y - Y0)*sin(o)*cos(p) + (Z - Z0)*cos(o)*cos(p)) - (c*(X - X0)*sin(k)*cos(p) + (Y - Y0)*(-sin(k)*sin(o)*sin(p) + cos(k)*cos(o)) + (Z - Z0)*(sin(k)*sin(p)*cos(o) + sin(o)*cos(k)))*sin(o)*cos(p)/((X - X0)*sin(p) - (Y - Y0)*sin(o)*cos(p) + (Z - Z0)*cos(o)*cos(p))**2;
end
function [fx_d_Z0] = make_fx_d_Z0(c,o,p,k,X0,Y0,Z0,