// ====================================================================== // LABORATÓRIO 08 - COMPUTAÇÃO GRÁFICA // ÁRVORE BINÁRIA // RAFAEL LAMARE SILVEIRA 009669 // ====================================================================== #include "colors.inc" #declare semente = seed(492); // Exemplo de arquivo de descricao de cena para POV-ray // Last edited on 2003-09-04 15:25:26 by stolfi // ====================================================================== // CÂMERA camera { location < 0.00, 30.00, 50.00 > // Posição do observador. right -1.0*x // Largura RELATIVA da imagem. up 0.75*y // Altura RELATIVA da imagem. sky -y // Qual direção é "para cima"? look_at < 0, 10, 10 > // Para onde a câmera está apontando. } // Nota: os parâmetros "right" e "up" devem ter a mesma proporção // que os parâmetros ${WIDTH} e ${HEIGHT} no Makefile. // ====================================================================== // FONTES DE LUZ light_source { 10 * < +50.0, +30.0, +50.0 > // Posição da lâmpada. color rgb 1.2 * < 1.00, 1.00, 1.00 > // Intensidade e corda luz. } light_source { 10 * < +50.0, -10.0, +10.0 > // Posição da lâmpada. color rgb 0.8 * < 1.00, 1.00, 1.00 > // Intensidade e corda luz. } // ====================================================================== // DESCRIÇÃO DA CENA background{ color rgb < 0.75, 0.80, 0.85 > } // ====================================================================== // OBJETOS // Indica o número de nós que a árvore irá conter // quanto maior seu valor, menor o número de nós. // Se 1 => árvore binária completa #declare esparsidade = 0.15; //altura da árvore = número de níveis + 1 //xx = coordenada x inicial //yy = coordenada y inicial //zz = coordenada z inicial //rr = raio dos nós //abertura = separação entre os nós filhos #macro arvore(altura,xx,yy,zz,rr,abertura) union { #local aleat1 = rand(semente); #local aleat2 = rand(semente); // Noh raiz da arvore sphere { , rr pigment { Red } } // Ligamentos dos nohs #if (altura > 0) #if (aleat1 > esparsidade) cylinder { , , 0.1*rr pigment { Green } } #end #if (aleat2 > esparsidade) cylinder { , , 0.1*rr pigment { Green } } #end #end // Filhos #if (altura != 0) #if (aleat1 > esparsidade) arvore(altura-1,abertura*(xx)+2*rr,yy+3.5*rr,zz,rr,abertura+rr/3) #end #if (aleat2 > esparsidade) arvore(altura-1,abertura*(xx)-2*rr,yy+3.5*rr,zz,rr,abertura+rr/3) #end #end } #end // Construção da árvore arvore(6,0,-6,0,1,1.5)