clc; clear all;

x=-2;y=6;z=3;
P = [x y z] %cartesian

theta = atan2d(sqrt(x.^2 + y.^2), z);
phi = atan2d(y,x);
r = sqrt(x.^2 + y.^2 + z.^2);

P1 = [r theta phi] %spherical point

x1 = r.*sind(theta).*cosd(phi);
y1 = r.*sind(theta).*sind(phi);
z1 = r.*cosd(theta);

theta1 = (y1.*cosd(theta).*cosd(phi)) + ((x1+z1).*cosd(theta).*sind(phi)); 
phi1 =  (-(y1).*sind(phi)) + ((x1+z1).*cosd(phi));
r1 = (y1.*sind(theta).*cosd(phi)) + ((x1+z1).*sind(theta).*sind(phi));

A_p = [r1 theta1 phi1] %vector