# make a regular prism, a regular 20-gon extruded 1 unit along z-axis
rp10 = regularprism( 10 )
# make 7 random directions
set.seed(0)
dir = matrix(rnorm(7*3),7,3)
# use basepoint in the interior of the zonohedron
raytrace( rp10, c(0.5,0.5,0.5), dir )
# base.1 base.2 base.3 direction.1 direction.2 direction.3 facetidx sign tmax ...
# 1 0.5 0.5 0.5 1.262954285 -0.294720447 -0.299215118 1 1 1.6710386 ...
# 2 0.5 0.5 0.5 -0.326233361 -0.005767173 -0.411510833 1 1 1.2150348 ...
# 3 0.5 0.5 0.5 1.329799263 2.404653389 0.252223448 6 -1 0.8724774 ...
# 4 0.5 0.5 0.5 1.272429321 0.763593461 -0.891921127 1 1 0.5605877 ...
# 5 0.5 0.5 0.5 0.414641434 -0.799009249 0.435683299 1 -1 1.1476226 ...
# 6 0.5 0.5 0.5 -1.539950042 -1.147657009 -1.237538422 1 1 0.4040279 ...
# 7 0.5 0.5 0.5 -0.928567035 -0.289461574 -0.224267885 1 1 2.2294766 ...
# use basepoint 0 on the boundary of the zonohedron
# note that only 2 directions point into the interior
raytrace( rp10, c(0,0,0), dir )
# base.1 base.2 base.3 direction.1 direction.2 direction.3 facetidx sign tmax ...
# 1 0 0 0 1.262954285 -0.294720447 -0.299215118 NA NA NA ...
# 2 0 0 0 -0.326233361 -0.005767173 -0.411510833 NA NA NA ...
# 3 0 0 0 1.329799263 2.404653389 0.252223448 6 -1 1.128580 ...
# 4 0 0 0 1.272429321 0.763593461 -0.891921127 NA NA NA ...
# 5 0 0 0 0.414641434 -0.799009249 0.435683299 1 -1 2.295245 ...
# 6 0 0 0 -1.539950042 -1.147657009 -1.237538422 NA NA NA ...
# 7 0 0 0 -0.928567035 -0.289461574 -0.224267885 NA NA NA ...
Run the code above in your browser using DataLab