TrajInPolygon | R Documentation |
Simply a wrapper around point.in.polygon
. The sp
package must be installed for this function to be called. sp
is not
automatically installed as a dependency of trajr.
TrajInPolygon(trj, boundary)
trj |
Trajectory to test |
boundary |
A polygon defining the region to be tested against. Can be
any structure that |
Integer array with a value for each point in the trajectory. Values are: 0: point is strictly exterior to boundary; 1: point is strictly interior to boundary; 2: point lies on the relative interior of an edge of boundary; 3: point is a vertex of boundary
point.in.polygon
, xy.coords
# Square arena
boundary <- data.frame(x = c(-10, 10, 10, -10), y = c(-10, -10, 10, 10))
# Generate a random trajectory
set.seed(1)
trj <- TrajGenerate(n = 10, stepLength = 2, angularErrorSd = .15)
# Test which points lie inside the boundary
print(TrajInPolygon(trj, boundary))
## [1] 1 1 1 1 1 1 0 0 0 0 0
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.