Lets Learn together... Happy Reading

" Two roads diverged in a wood, and I,
I took the one less traveled by,
And that has made all the difference "-Robert Frost

Cartesian to Polar co-ordinates:


            To find the angle of a point in the Cartesian co-ordinates, convert the co-ordinates to polar co-ordinates using the function cart2pol(x,y) . The output will be radius and the angle. The radius is calculated from the origin to the given point. The theta value will be in radians. The function rad2deg(theta) can be used to convert the radians to degree.

MATLAB CODE:
I am using this plot function to display the points in the Cartesian co-ordinates.
plot([-10 -3 10 0 0 0 0 0 2 ] ,[0 0  0 0 6 10 -10 0 3],'--rs','LineWidth',2,'MarkerFaceColor','k');
%180 degrees
[theta,radius]=cart2pol(-2,0);
deg=rad2deg(theta);

%display the radius , angle and the co-ordinates in the axes.

degree=strcat('deg:',num2str(deg));
rad=strcat('radius:',num2str(radius));
text(-3,-2,degree);
text(-3,-3,rad);
           
%90 degrees
[theta,radius]=cart2pol(0,6);
deg=rad2deg(theta);

degree=strcat('deg:',num2str(deg));
rad=strcat('radius:',num2str(radius));
text(-3,6,degree);
text(-3,5,rad);

%45 degrees
[theta,radius]=cart2pol(2,2);
deg=rad2deg(theta);

degree=strcat('deg:',num2str(deg));
rad=strcat('radius:',num2str(radius));
text(4,3,degree);
text(4,2,rad);



like button Like "IMAGE PROCESSING" page

0 comments:

Enjoyed Reading? Share Your Views

Previous Post Next Post Home
Google ping Hypersmash.com