Used in the overlap_with_objects function for creating
nodes of which their presence within an agent can be checked in an efficient
way (see moving_options and
in_object). Currently works for all
instances of object-class, but only returns
NULL for the segment-class.
Usage
nodes_on_circumference(object, ...)
# S4 method for class 'polygon'
nodes_on_circumference(object, space_between = 0.05, cpp = FALSE)
# S4 method for class 'circle'
nodes_on_circumference(object, space_between = 0.05, cpp = FALSE)
# S4 method for class 'segment'
nodes_on_circumference(object, ...)Arguments
- object
Object of
object-class.- ...
Arguments passed on to the methods of this generic
- space_between
Numeric denoting the space to leave between the circumference of the object and the nodes to create. When
outside = TRUE,space_betweendistance is created to the outside of the object, while ifoutside = FALSEthis same distance is created towards the inside of the object. Defaults to5e-2.- cpp
Logical denoting whether to use the Rcpp alternative (
TRUE) or the R alternative of this function (FALSE). Defaults toFALSE.
Details
Related to the add_nodes with the main difference
being that the add_nodes adds nodes around or
within an object, while nodes_on_circumference adds nodes directly on
the circumference of an object.
Note that while rectangle-class is not explicitly
mentioned here, this method does work for this class of objects.
Examples
# Create an object
my_circle <- circle(center = c(0, 0), radius = 1)
# Generate nodes that fall around this circle with a distance of 1 around
# the circle
nodes_on_circumference(my_circle, space_between = pi / 2)
#> [,1] [,2]
#> [1,] 1.000000e+00 0.000000e+00
#> [2,] 6.123234e-17 1.000000e+00
#> [3,] -1.000000e+00 1.224647e-16
#> [4,] -1.836970e-16 -1.000000e+00
# Note that for segments, this function returns NULL
my_segment <- segment(from = c(0, 0), to = c(2, 2))
nodes_on_circumference(my_segment)
#> NULL