08.02.2015 Views

Programação Funcional e Concorrente com Scheme

Programação Funcional e Concorrente com Scheme

Programação Funcional e Concorrente com Scheme

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

notas de aula - Jerônimo C. Pellegrini<br />

• in-julia é chamada, <strong>com</strong> o <strong>com</strong>plexo formado pelo ponto (x, y) e <strong>com</strong> o limite de<br />

2.<br />

( define quadractic-in-julia <br />

( lambda (x y x-size y-size )<br />

( let (( half-x (/ x-size 2))<br />

( half-y (/ y-size 2))<br />

( scale-factor (/ 3 x-size )))<br />

( let (( tr-x (- x half-x ))<br />

( tr-y (- y half-y )))<br />

( let (( sc-x (* tr-x scale-factor ))<br />

( sc-y (* tr-y scale-factor )))<br />

( in-julia <strong>com</strong>plex-quad<br />

( make-rectangular sc-x sc-y )<br />

2))))))<br />

Agora só nos falta make-julia, que efetivamente constrói a imagem passando a<br />

função quadratic-in-julia para for-each-pixel!<br />

( define make-julia<br />

( lambda ( x-size y-size fun )<br />

( let (( img ( make-image x-size y-size )))<br />

( for-each-pixel ! img<br />

img )))<br />

( lambda (x y)<br />

( fun x y<br />

x-size<br />

y-size )))<br />

Geramos a imagem do conjunto de Julia para f(z) = z 2 − 0.2 + 0.5ϕi:<br />

( let (( julia-set ( make-julia 300<br />

( draw-image julia-set<br />

400<br />

" julia-set . pbm "))<br />

quadractic-in-julia )))<br />

Versão Preliminar<br />

O conteúdo do arquivo julia-set.pbm será a figura abaixo:<br />

[ 27 de outubro de 2010 at 15:47 ]<br />

125

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!