clay - a = a + a_; b = b + b_; n = n + 1; end end end if n...

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

View Full Document Right Arrow Icon
function [] = clay() % Setup the figure/windows for the clay close all figure('Name','Clay'); plot(-1. -1) axis([0 19 0 19]) set(gca,'xTick',0:20) set(gca,'yTick',0:20) grid on shg state = zeros(20,20); while 1 state = process(state); end end function [state] = process(state) [x y] = ginput(1); [x y] = position(x,y); if (state(x,y) == 0) z = drawO(x, y); state(x,y) = z; else z = state(x,y); state(x,y) = 0; clearO(z); end n = 0; a = 0; b = 0; for i = 1:20 for j = 1:20 if state(i,j) > 0 [a_ b_] = g(i-1,j-1);
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: a = a + a_; b = b + b_; n = n + 1; end end end if n > 0 mag = sqrt(a^2+b^2); xlabel(mag/n); end end function [a b] = g(x,y) mag = x^2 + y^2; a = x/mag; b = y/mag; end function [x y] = position(x,y) x = round(x); y = round(y); if x < 0 x = 0; end if y < 0 y = 0; end end function z = drawO(x, y) hold on t = 0:0.1:2*pi; a = cos(t)/4; b = sin(t)/4; z = plot(x+a, y+b); hold off end function clearO(z) delete(z); end...
View Full Document

This note was uploaded on 03/12/2012 for the course CS 3220 taught by Professor Marschner during the Spring '09 term at Cornell University (Engineering School).

Page1 / 2

clay - a = a + a_; b = b + b_; n = n + 1; end end end if n...

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

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