Exercise Geometrical transformations xercise The following f
Solution
All the functions have been written in MATLAB
1) Cartesian to Cylindrical(Cart2Cyl)
function[rho,theta,z]=Cart2Cyl(x,y,z)
rho=sqrt(x^2+y^2);
theta=atan2d(y,x);
2) Cylindrical to Cartesian(Cyl2Cart)
function[x,y,z]=Cyl2Cart(rho,theta,z)
x=rho*cosd(theta);
y=rho*sind(theta);
3)Cartesian to Spherical(Cart2Sph)
function[r,theta,phi]=Cart2Sph(x,y,z)
r=sqrt(x^2+y^2+z^2);
theta=atan2d(y,x);
phi=atan2d(sqrt(x^2+y^2),z);
4)Spherical to Cartesian (Sph2Cart)
function[x,y,z]=Sph2Cart(r,theta,phi)
x=r*sind(phi)*cosd(theta);
y=r*sind(phi)*sind(theta);
z=r*cosd(phi);
5)Cylindrical to Spherical(Cyl2Sph)
function[r,theta,phi]=Cyl2Sph(rho,theta,z)
phi=acosd(rho,z);
r=sqrt(rho^2+z^2);
6)Spherical to Cylindrical(Sph2Cyl)
function[rho,theta,z]=Sph2Cyl(r,theta,phi)
rho=r*sind(phi);
z=r*cosd(phi);
