Is a more specific version of position that
works for all extensions of the object-class.
Usage
center(object)
center(object) <- value
# S4 method for class 'polygon'
center(object)
# S4 method for class 'polygon'
center(object) <- value
# S4 method for class 'rectangle'
center(object)
# S4 method for class 'rectangle'
center(object) <- value
# S4 method for class 'circle'
center(object)
# S4 method for class 'circle'
center(object) <- value
# S4 method for class 'segment'
center(object)
# S4 method for class 'segment'
center(object) <- valueArguments
- object
An instance of the
object-classor theagent-class.- value
Value with which to replace the original value of the
centerslot.
Examples
# Initialize a circle
my_circle <- circle(center = c(0, 0),
radius = 1)
# Access the center slot for the circle
center(my_circle)
#> An object of class "coordinate"
#> [1] 0 0
# Change the center slot for the circle
center(my_circle) <- c(1, 1)
center(my_circle)
#> An object of class "coordinate"
#> [1] 1 1
# Note that for some object, changing the center also changes other slots
my_rectangle <- rectangle(center = c(0, 0),
size = c(2, 2))
points(my_rectangle)
#> [,1] [,2]
#> [1,] -1 -1
#> [2,] -1 1
#> [3,] 1 1
#> [4,] 1 -1
center(my_rectangle) <- c(1, 1)
points(my_rectangle)
#> [,1] [,2]
#> [1,] 0 0
#> [2,] 0 2
#> [3,] 2 2
#> [4,] 2 0