Skip to contents

Usage

size(object)

size(object) <- value

# S4 method for class 'rectangle'
size(object)

# S4 method for class 'rectangle'
size(object) <- value

# S4 method for class 'circle'
size(object)

# S4 method for class 'circle'
size(object) <- value

# S4 method for class 'segment'
size(object)

# S4 method for class 'segment'
size(object) <- value

# S4 method for class 'agent'
size(object)

# S4 method for class 'agent'
size(object) <- value

Arguments

object

An instance of the object-class or agent-class.

value

Value with which to replace the original value of the size slot.

Details

Note that for circle-class, this getter outputs the radius (and similarly, the setter changes the radius).

Examples

# Initialize a circle
my_circle <- circle(center = c(0, 0), 
                    radius = 1)

# Access the radius slot in circle
size(my_circle)
#> [1] 1

# Change the radius slot in circle
size(my_circle) <- 2
size(my_circle)
#> [1] 2

# Also works for objects in which other slots change with a change in size
my_rectangle <- rectangle(center = c(0, 0), 
                          size = c(2, 2))

# Access points before and after changing its size
points(my_rectangle)
#>      [,1] [,2]
#> [1,]   -1   -1
#> [2,]   -1    1
#> [3,]    1    1
#> [4,]    1   -1

size(my_rectangle) <- c(4, 4)
points(my_rectangle) 
#>      [,1] [,2]
#> [1,]   -2   -2
#> [2,]   -2    2
#> [3,]    2    2
#> [4,]    2   -2