zonohedron-raytrace {zonohedra}R Documentation

compute the intersection of a ray, based in the interior of a zonohedron, and the boundary of that zonohedron

Description

The open ray with basepoint \bold{b} and non-zero direction \bold{d} is the set of the form \bold{b} + t \bold{d} where t > 0.

This function computes the intersection of an open ray and the boundary of a zonohedron Z. The basepoint is normally required to be in the interior of Z, but an exception is made if the basepoint is 0, and on the boundary of Z, and the direction points into the interior of Z. In these two cases the intersection of the open ray and the boundary of Z is unique. In the second case, the basepoint is also allowed to be the sum of all the generators - the so-called white point of Z.

Usage

## S3 method for class 'zonohedron'
raytrace( x, base, direction, invert=FALSE, plot=FALSE, ... )

Arguments

x

a zonohedron object as returned by the constructor zonohedron()

base

a numeric 3-vector - the basepoint of all the rays. base must either be in the interior of x, or 0 or the white point and on the boundary of x.

direction

a numeric Mx3 matrix with M non-zero directions in the rows. The basepoint and these directions define M rays.
direction can also be a numeric vector that can be converted to such a matrix, by row.

invert

if TRUE, then compute a point in the unit cube that maps to the point on the boundary of x and add it as a column in the returned data.frame

plot

if TRUE, the computed rays, up to the boundary, are added to an existing plot of the zonohedron x, see plot.zonohedron(). The segments are drawn in the color red. If there is no open plot, a warning is issued.

...

not used

Details

If plot is TRUE, the rays are drawn with rgl::segments3d().

Value

raytrace.zonohedron() returns a data.frame with M rows and these columns:

base

the given basepoint - this is the same in every row

direction

the given direction

facetidx

the index of the facet (a zonogon) where ray exits the zonohedron

sign

of the facet, either +1 or -1

tmax

ray parameter of the intersection with the exit facet, always positive

point

the point on the boundary; the intersection of the ray and the facet

timetrace

the computation time, in seconds

And if invert is TRUE, then these columns are added:

distance

signed distance to the boundary of x

pcube

a point in the unit cube that maps to boundary

transitions

the number of transitions in pcube - a non-negative even integer

If base and direction in a row cannot be processed, the rest of the row is NA.

If the row names of direction are unique, they are copied to the row names of the output.

In case of error, the function returns NULL.

Note

The package rgl is required for 3D plotting.

See Also

zonohedron(), plot.zonohedron(), section.zonohedron(), invertboundary(), raytrace.zonogon()

Examples

#   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   ...

[Package zonohedra version 0.3-0 Index]