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
and non-zero direction
is the set of the form
where
.
This function computes the intersection of an open ray
and the boundary of a zonohedron .
The basepoint is normally required to be in the interior
of
, but an exception is made if the basepoint is 0,
and on the boundary of
,
and the direction points into the interior of
.
In these two cases the intersection of the open ray
and the boundary of
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
.
Usage
## S3 method for class 'zonohedron'
raytrace( x, base, direction, invert=FALSE, plot=FALSE, ... )
Arguments
x |
a zonohedron object as returned by the constructor |
base |
a numeric 3-vector - the basepoint of all the rays.
|
direction |
a numeric Mx3 matrix with M non-zero directions in the rows.
The basepoint and these directions define M rays.
|
invert |
if |
plot |
if |
... |
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 |
pcube |
a point in the unit cube that maps to |
transitions |
the number of transitions in |
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 ...