This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: else % Generate a random point in the rectangle--a basis for the subdivision of % the rectangle into four smaller rectangles c = a + rand*(L); % c and d are random x and y coordinates of pt d = b + rand*(W); maxWidth = b + (7/8)*(W); minWidth = b + (3/8)*(W); maxLength = a + (3/4)*(L); minLength = a + (1/4)*(L); while ((d > maxWidth)||(d < minWidth))||((c > maxLength)||(c < minLength)) % Generate a new coordinate since last coordinate was 'bad' In other % words, last coordinate was not within specified bounds. . c = a + rand*(L); d = b + rand*(W); end % RECURSION - call the fcn again four times, one for each of the four new % rectangles. . RandomMondrian(a,d,c-a,b+W-d,Level+1) RandomMondrian(c,d,a+L-c,b+W-d,Level+1) RandomMondrian(a,b,c-a,d-b,Level+1) RandomMondrian(c,b,a+L-c,d-b,Level+1) end...
View Full Document
This note was uploaded on 09/12/2009 for the course CS 100 taught by Professor Fan/vanloan during the Fall '07 term at Cornell.
- Fall '07