inside {zonohedra} | R Documentation |
test points for being inside a zonotope
Description
Test points for being inside a zonotope. The boundary points are considered to be inside.
Usage
## S3 method for class 'zonotope'
inside( x, p )
Arguments
x |
a zonotope object - a zonohedron, zonogon, or zonoseg |
p |
an NxM numeric matrix, where M is the dimension of the zonotope.
The points to be tested are in the rows.
|
Details
The given zonotope is viewed as the intersection of slabs;
there is a slab for each hyperplane in the simplified matroid.
For each slab a signed distance to boundary of the slab
is computed.
For points outside the slab the distance is positive,
for points on the boundary, the distance is 0,
and for points in the interior of the slab the distance is negative.
The distance to the zonotope is computed as the
maximum over all these slab distances,
and the critical hyperplane index is recorded.
A point is inside iff the zonotope distance \le
0.
Value
inside.zonotope()
returns a data.frame
with N rows and these columns:
p |
the given point |
inside |
whether the point is inside the zonotope. For boundary points, |
distance |
the distance from the point to the zonotope. For boundary points, |
idxhyper |
the index of the critical hyperplane in the simplified matroid. This is the index of the slab where the maximum slab distance was taken. For a zonoseg there is only 1 hyperplane (the empty set) so this is always 1. |
If the row names of p
are unique,
they are copied to the row names of the output.
In case of error, the function returns NULL
.
See Also
Examples
zono1 = zonoseg( c(1,-2,3,0,-3,-4) )
getsegment(zono1)
# [1] -9 4
p = c( 0, -3*pi, pi, 2*pi, getsegment(zono1) )
inside( zono1, p )
# p inside distance idxhyper
# 1 0.000000 TRUE -4.0000000 1
# 2 -9.424778 FALSE 0.4247780 1
# 3 3.141593 TRUE -0.8584073 1
# 4 6.283185 FALSE 2.2831853 1
# 5 -9.000000 TRUE 0.0000000 1
# 6 4.000000 TRUE 0.0000000 1