Skip to contents

Function to normalize coordinates between zero and one while keep scaling

Usage

normalizeCoordinates(coords)

Arguments

coords

matrix; matrix with coordinates

Value

matrix; coordinates scaled between 0 and 1

Examples

matrix_R <- matrix(c(
    0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 1, 1, 1, 1, 1, 0, 0, 0,
    0, 1, 1, 0, 0, 1, 1, 0, 0,
    0, 1, 1, 0, 0, 1, 1, 0, 0,
    0, 1, 1, 1, 1, 1, 0, 0, 0,
    0, 1, 1, 0, 1, 1, 0, 0, 0,
    0, 1, 1, 0, 0, 1, 1, 0, 0,
    0, 1, 1, 0, 0, 1, 1, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0
), nrow = 9, byrow = TRUE)
coords <- xyCoordinates(matrix_R)
normalizeCoordinates(coords)
#>               x         y
#>  [1,] 0.0000000 0.0000000
#>  [2,] 0.1666667 0.0000000
#>  [3,] 0.3333333 0.0000000
#>  [4,] 0.5000000 0.0000000
#>  [5,] 0.6666667 0.0000000
#>  [6,] 0.8333333 0.0000000
#>  [7,] 1.0000000 0.0000000
#>  [8,] 0.0000000 0.1666667
#>  [9,] 0.1666667 0.1666667
#> [10,] 0.3333333 0.1666667
#> [11,] 0.5000000 0.1666667
#> [12,] 0.6666667 0.1666667
#> [13,] 0.8333333 0.1666667
#> [14,] 1.0000000 0.1666667
#> [15,] 0.0000000 0.3333333
#> [16,] 0.5000000 0.3333333
#> [17,] 0.0000000 0.5000000
#> [18,] 0.5000000 0.5000000
#> [19,] 0.6666667 0.5000000
#> [20,] 0.0000000 0.6666667
#> [21,] 0.1666667 0.6666667
#> [22,] 0.3333333 0.6666667
#> [23,] 0.5000000 0.6666667
#> [24,] 0.6666667 0.6666667
#> [25,] 0.8333333 0.6666667
#> [26,] 1.0000000 0.6666667
#> [27,] 0.1666667 0.8333333
#> [28,] 0.3333333 0.8333333
#> [29,] 0.8333333 0.8333333
#> [30,] 1.0000000 0.8333333