Skip to contents

Takes a default matrix and embeds circles within the matrix.

Usage

circle_matrix(m, n, x.center, y.center, r, f = 1)

Arguments

m

A int that is the number of rows of the matrix

n

A int that is the number of the columns of the matrix.

x.center

A vector of x coordinate center position of the circle.

y.center

A vector of y coordinate center position of the circle.

r

A vector of integers denoting the different circle radii.

f

A vector of values that specify what the inside of the circles should be.

Value

A matrix with circles imprinted within its dimensions.

Author

James Balamuta

Examples

# Generate a basic circle matrix
circle_matrix(10, 10, 3, 4, 2)
#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#>  [1,]    0    0    0    1    0    0    0    0    0     0
#>  [2,]    0    0    1    1    1    0    0    0    0     0
#>  [3,]    0    1    1    1    1    1    0    0    0     0
#>  [4,]    0    0    1    1    1    0    0    0    0     0
#>  [5,]    0    0    0    1    0    0    0    0    0     0
#>  [6,]    0    0    0    0    0    0    0    0    0     0
#>  [7,]    0    0    0    0    0    0    0    0    0     0
#>  [8,]    0    0    0    0    0    0    0    0    0     0
#>  [9,]    0    0    0    0    0    0    0    0    0     0
#> [10,]    0    0    0    0    0    0    0    0    0     0

# Generate two circles within the matrix
circle_matrix(10, 20, c(3,6), c(4,6), c(2,2))
#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
#>  [1,]    0    0    0    1    0    0    0    0    0     0     0     0     0
#>  [2,]    0    0    1    1    1    0    0    0    0     0     0     0     0
#>  [3,]    0    1    1    1    1    1    0    0    0     0     0     0     0
#>  [4,]    0    0    1    1    1    1    0    0    0     0     0     0     0
#>  [5,]    0    0    0    1    1    1    1    0    0     0     0     0     0
#>  [6,]    0    0    0    1    1    1    1    1    0     0     0     0     0
#>  [7,]    0    0    0    0    1    1    1    0    0     0     0     0     0
#>  [8,]    0    0    0    0    0    1    0    0    0     0     0     0     0
#>  [9,]    0    0    0    0    0    0    0    0    0     0     0     0     0
#> [10,]    0    0    0    0    0    0    0    0    0     0     0     0     0
#>       [,14] [,15] [,16] [,17] [,18] [,19] [,20]
#>  [1,]     0     0     0     0     0     0     0
#>  [2,]     0     0     0     0     0     0     0
#>  [3,]     0     0     0     0     0     0     0
#>  [4,]     0     0     0     0     0     0     0
#>  [5,]     0     0     0     0     0     0     0
#>  [6,]     0     0     0     0     0     0     0
#>  [7,]     0     0     0     0     0     0     0
#>  [8,]     0     0     0     0     0     0     0
#>  [9,]     0     0     0     0     0     0     0
#> [10,]     0     0     0     0     0     0     0

# Different fills
circle_matrix(10, 20, c(3,6), c(4,6), c(2,2), f = c(1,2))
#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
#>  [1,]    0    0    0    1    0    0    0    0    0     0     0     0     0
#>  [2,]    0    0    1    1    1    0    0    0    0     0     0     0     0
#>  [3,]    0    1    1    1    1    1    0    0    0     0     0     0     0
#>  [4,]    0    0    1    1    1    2    0    0    0     0     0     0     0
#>  [5,]    0    0    0    1    2    2    2    0    0     0     0     0     0
#>  [6,]    0    0    0    2    2    2    2    2    0     0     0     0     0
#>  [7,]    0    0    0    0    2    2    2    0    0     0     0     0     0
#>  [8,]    0    0    0    0    0    2    0    0    0     0     0     0     0
#>  [9,]    0    0    0    0    0    0    0    0    0     0     0     0     0
#> [10,]    0    0    0    0    0    0    0    0    0     0     0     0     0
#>       [,14] [,15] [,16] [,17] [,18] [,19] [,20]
#>  [1,]     0     0     0     0     0     0     0
#>  [2,]     0     0     0     0     0     0     0
#>  [3,]     0     0     0     0     0     0     0
#>  [4,]     0     0     0     0     0     0     0
#>  [5,]     0     0     0     0     0     0     0
#>  [6,]     0     0     0     0     0     0     0
#>  [7,]     0     0     0     0     0     0     0
#>  [8,]     0     0     0     0     0     0     0
#>  [9,]     0     0     0     0     0     0     0
#> [10,]     0     0     0     0     0     0     0