demo/demo4.R

library(vecspace)
library(vecshapes)
library(raytrace)

p.surf <- RT.Surface(rgb = function(x,y) { if ((x %/% 20) %% 2 == ((y %/% 20) %% 2)) return (c(0.3,0.6,1)) else return (c(0.15,0.3,.5)) },
                     matteness=1 )
p <- Spc.MakePlane(point=c(0,-10,0),normal=c(0,1,0), properties=p.surf,direction.north=c(0,0,1),direction.east=c(1,0,0))
p <- Spc.Rotate(p,pivot.angle=c(0,20,0))

#sp.surf <- RT.Surface(rgb = c(0.6,0.8,0.4),matteness=0.5)
#sp <- Spc.MakeSphere(c(-4,1,10),1.4,properties=sp.surf)

tea.surf <- RT.Surface(rgb = c(1,1,1),matteness=1)
tea <- Spc.MakeTeapotahedron(c(-4,-2,15),3,tea.surf)
tea <- Spc.Rotate(tea,pivot.angle=c(-90,0,0))

dod.surf <- RT.Surface(rgb = c(0.3,1,0.4), matteness=0.5)
dod <- Spc.MakeDodecahedron(c(3,-2,15),2,dod.surf)

sp2.surf <- RT.Surface(rgb = c(1,1,1),matteness=0.2)
sp2 <- Spc.MakeSphere(c(-3,2,15),1.4,properties=sp2.surf)

cu.surf <- RT.Surface(rgb = c(1,0.3,0.1), matteness=1)
cu <- Spc.Rotate(Spc.MakeCuboid(c(2,1,10),c(1,1,1),properties=cu.surf),pivot.angle=c(20,40,60))

world <- Spc.Combine(list(p,sp2,cu,dod,tea), bound=FALSE)

w=50
h=50

cam <- RT.PinholeCamera()
pic <- RT.trace.PinholeCamera(world=world,camera=cam,pixel.width=w,pixel.height=h)
RT.plot(pic,w,h)
JerBoon/raytrace documentation built on May 17, 2019, 6:19 p.m.