tunnel - % circle's center. For example, if the radius was...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 %========================================================================== % Problem 8. Designing a Tunnel. %-------------------------------------------------------------------------- % % Create a recursive function, tunnel.m, that will take in three inputs: a % radius (r), and two scalars, x and y. Plot a circle using the % coordinates (x,y) as the center and the radius (r) as your radius. Count % theta as 100 evenly distributed points from 0 to 2*pi. As long as the % radius of the current circle is at least a length of 0.1, plot an % additional circle whose radius is 95% of the previous circle's radius, % as well as add .25 to the x-coordinate and y-coordinate of the previous
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % circle's center. For example, if the radius was 1 and (x,y) was (0,0) the % next circle would have a radius of .95 and the new center of the next % circle would be (.25,.25). (Please refer to tunneltest.jpg for example.) % You *must* use recursion to write this code. REMEMBER to label the title % as 'Tunnel', your x-axis as 'x-axis', and your y-axis as 'y-axis'. function tunnel(r, x, y) th = linspace(0,(2*pi),100) plot(x+r*cos(th),y+r*sin(th)) axis('square') title('Tunnel') xlabel('x-axis') ylabel('y-axis') while r>=0.1 hold on r = 0.95*r x = x + 0.25 y = y + 0.25 plot(x+r*cos(th),y+r*sin(th)) end...
View Full Document

This note was uploaded on 07/06/2009 for the course CS 1371 taught by Professor Stallworth during the Fall '08 term at Georgia Tech.

Ask a homework question - tutors are online