<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:10pt"><div style="RIGHT: auto"><SPAN style="RIGHT: auto"><VAR id=yui-ie-cursor></VAR>Rubem,</SPAN></div>
<div style="RIGHT: auto"><SPAN style="RIGHT: auto"></SPAN> </div>
<div style="RIGHT: auto"><SPAN style="RIGHT: auto">Este não é o meu caso, pois não tenho função, só um grid e o sólido é irregular. Por exemplo, como poderia calcular o volume da seguinte esfera:</SPAN></div>
<div style="RIGHT: auto"><SPAN style="RIGHT: auto"></SPAN> </div>
<div style="RIGHT: auto"><SPAN style="RIGHT: auto">library(lattice)<BR>x <- 0:100<BR>y <- 0:100<BR>z <- 0:100<BR>r <- 30<BR>xyz <- expand.grid(x,y,z)<BR>dados <- cbind(xyz,as.numeric(sqrt(rowSums((xyz-50.5)^2))<=r))<BR>colnames(dados) <- c("x","y","z","var")<BR>cloud(z ~ x * y, data = dados[dados$var==1,], groups = var, screen = list(x = -90, y = 70),<BR>xlim = c(0,100), ylim = c(0,100), zlim = c(0,100))</SPAN></div>
<div style="RIGHT: auto"><SPAN style="RIGHT: auto"></SPAN> </div>
<div style="RIGHT: auto"><SPAN style="RIGHT: auto">Att,</SPAN></div>
<div style="RIGHT: auto"><SPAN style="RIGHT: auto"></SPAN> </div>
<div style="RIGHT: auto"><SPAN style="RIGHT: auto">Tiago Viera.</SPAN></div>
<div style="RIGHT: auto"><BR style="RIGHT: auto"></div>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: arial, helvetica, sans-serif">
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">
<DIV dir=ltr><FONT face=Arial size=2>
<DIV class=hr style="BORDER-RIGHT: #ccc 1px solid; PADDING-RIGHT: 0px; BORDER-TOP: #ccc 1px solid; PADDING-LEFT: 0px; FONT-SIZE: 0px; PADDING-BOTTOM: 0px; MARGIN: 5px 0px; BORDER-LEFT: #ccc 1px solid; LINE-HEIGHT: 0; PADDING-TOP: 0px; BORDER-BOTTOM: #ccc 1px solid; HEIGHT: 0px" readonly="true" contenteditable="false"></DIV><B><SPAN style="FONT-WEIGHT: bold">De:</SPAN></B> Rubem Kaipper Ceratti <rubem_ceratti@yahoo.com.br><BR><B><SPAN style="FONT-WEIGHT: bold">Para:</SPAN></B> "r-br@listas.c3sl.ufpr.br" <r-br@listas.c3sl.ufpr.br>; Tiago Vieira <tiagovieira7@yahoo.com.br> <BR><B><SPAN style="FONT-WEIGHT: bold">Enviadas:</SPAN></B> Sexta-feira, 23 de Março de 2012 9:25<BR><B><SPAN style="FONT-WEIGHT: bold">Assunto:</SPAN></B> Re: [R-br] Cálculo de Volume de Sólido Irregular<BR></FONT></DIV><BR>
<DIV id=yiv1259856091>
<DIV>
<DIV style="FONT-SIZE: 10pt; COLOR: #000; FONT-FAMILY: arial, helvetica, sans-serif; BACKGROUND-COLOR: #fff">
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: arial, helvetica, sans-serif"><SPAN>Tiago,</SPAN></DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: arial, helvetica, sans-serif"><SPAN><BR></SPAN></DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: arial, helvetica, sans-serif"><SPAN>Se for possível calcular o valor da função em qualquer ponto, então talvez você possa utilizar integração por Monte Carlo. Por exemplo:</SPAN></DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: arial, helvetica, sans-serif"><SPAN><BR></SPAN></DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: arial, helvetica, sans-serif"><SPAN><BR></SPAN></DIV>
<DIV><SPAN style="FONT-SIZE: 13px">
<DIV style="FONT-FAMILY: courier, monaco, monospace, sans-serif"># Cálculo de volume (1/8 de esfera de raio r)</DIV>
<DIV style="FONT-FAMILY: courier, monaco, monospace, sans-serif">r<-1</DIV>
<DIV style="FONT-FAMILY: courier, monaco, monospace, sans-serif"><BR></DIV>
<DIV style="FONT-FAMILY: courier, monaco, monospace, sans-serif">ux<-runif(2e4,0,r)</DIV>
<DIV style="FONT-FAMILY: courier, monaco, monospace, sans-serif">uy<-runif(2e4,0,r)</DIV>
<DIV style="FONT-FAMILY: courier, monaco, monospace, sans-serif">uz<-runif(2e4,0,r)</DIV>
<DIV style="FONT-FAMILY: courier, monaco, monospace, sans-serif"><BR></DIV>
<DIV style="FONT-FAMILY: courier, monaco, monospace, sans-serif">id<-ux^2+uy^2+uz^2<=r^2</DIV>
<DIV style="FONT-FAMILY: courier, monaco, monospace, sans-serif"><BR></DIV>
<DIV style="FONT-FAMILY: courier, monaco, monospace, sans-serif">mean(id)*r^3 # Aproximado</DIV>
<DIV style="FONT-FAMILY: courier, monaco, monospace, sans-serif">4*pi*r^3/(3*8) # Exato</DIV>
<DIV style="FONT-FAMILY: courier, monaco, monospace, sans-serif"><BR></DIV>
<DIV style="FONT-FAMILY: courier, monaco, monospace, sans-serif"><BR></DIV>
<DIV style="FONT-FAMILY: courier, monaco, monospace, sans-serif"># Vizualização</DIV>
<DIV style="FONT-FAMILY: courier, monaco, monospace, sans-serif">np=200</DIV>
<DIV style="FONT-FAMILY: courier, monaco, monospace, sans-serif">x<-seq(0,r,l=np)</DIV>
<DIV style="FONT-FAMILY: courier, monaco, monospace, sans-serif">z<-outer(x,x,function(x,y) sqrt(r^2-x^2-y^2))</DIV>
<DIV style="FONT-FAMILY: courier, monaco, monospace, sans-serif"><BR></DIV>
<DIV style="FONT-FAMILY: courier, monaco, monospace, sans-serif">library(rgl)</DIV>
<DIV style="FONT-FAMILY: courier, monaco, monospace, sans-serif">persp3d(x,x,z)</DIV>
<DIV style="FONT-FAMILY: courier, monaco, monospace, sans-serif">points3d(ux,uy,uz,pch=20,col=ifelse(id==TRUE,4,2))</DIV>
<DIV style="FONT-FAMILY: courier, monaco, monospace, sans-serif"><BR></DIV>
<DIV style="FONT-FAMILY: courier, monaco, monospace, sans-serif"><BR></DIV>
<DIV>Att.,</DIV>
<DIV>Rubem</DIV></SPAN></DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: arial, helvetica, sans-serif"><BR></DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: arial, helvetica, sans-serif">
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times, serif"><BR></DIV></DIV></DIV></DIV></DIV><BR><BR></DIV></DIV></div></body></html>