{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Programming 3

# Programming 3 - Problem Source Programming 3 Problem 1...

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

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;

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

View Full Document
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 ((X > 0) & (Y > 0)) elseif ((X > 0) & (Y < 0)) theta = theta + 2*pi; elseif ((X < 0) & (Y > 0)) theta = theta + pi; elseif ((X < 0) & (Y < 0)) theta = theta + pi; end theta=theta*(180/pi); if (theta>180) theta=-(360-theta); end R = sqrt((X*X) + (Y*Y)); end Test Runs: >> [a,b]=RtoP(-3,-4) a = 5 b = -126.8699 >> [a,b]=RtoP(0,0) a = 0 b = 0 Problem Source: Programming 3 Problem 2 Given: Magnitude and Direction of 2 forces Required: Resultant vector force
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### 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
Ask a homework question - tutors are online