Programming 3 - Problem Source: Programming 3 Problem 1...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Problem Source: Programming 3 Problem 1 Given: Rectangular Coordinates Required: Polar Coordinates Solution: Start Input X Y R = (X*X + Y*Y)^0.5 IF X=0 IF Y>0 IF Y<0 Yes Yes Yes No IF Y=0 IF X>0 IF X<0 Yes Yes No No Yes Theta= arctan(Y/X) No IF X>0 and Y<0 IF X<0 and Y>0 IF X<0 and Y>0 Yes No No Yes Yes Stop IF Y=0 and X=0 Theta = 90 Theta = -90 Theta = 0 Theta = 180 Theta= theta- 90 Theta = theta + 90 Theta = theta - 180 Theta = 0 R = 0 % function RToP Tran, Nathaniel 16184-F % Translates X,Y coordinates to polar form (R, Theta) % Call statement RToP(X,Y) function [R, theta] = RToP(X,Y) if (X == 0)&&(Y==0) R =0; theta = 0;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
else if (X == 0) if (Y > 0) theta = pi/2; elseif (Y < 0) theta = -pi/2; else theta = 0; end else theta = atan(Y/X); end if (Y == 0) if (X > 0) theta = 0; elseif (X < 0) theta = -pi; else theta = 0; end end if elseif ((X > 0) & (Y < 0)) theta = theta + 2*pi; elseif theta = theta + pi; elseif theta = theta + pi; end theta=theta*(180/pi); if (theta>180) theta=-(360-theta);
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/30/2008 for the course ENGE 1024 taught by Professor Dcohanehi during the Fall '06 term at Virginia Tech.

Page1 / 8

Programming 3 - Problem Source: Programming 3 Problem 1...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online