Skip to contents

The previous and the next point

Usage

# S4 method for sfc_base
sfc_previous_point(p, x, rot, length = 1)

# S4 method for sfc_base
sfc_next_point(p, x, rot, length = 1)

Arguments

p

An sfc_base object.

x

The coordinate of the current point.

rot

Rotation of the current point.

length

Length of the segment between the previous/next point and the current point.

Value

A vector of length two.

Examples

sfc_previous_point(BASE_R, c(0, 0), 0)
#>              [,1] [,2]
#> [1,] -1.83697e-16   -1
sfc_previous_point(BASE_R, c(0, 0), 90)
#>      [,1]          [,2]
#> [1,]    1 -2.449294e-16
sfc_previous_point(BASE_R, c(0, 0), 180)
#>              [,1] [,2]
#> [1,] 3.061617e-16    1
sfc_previous_point(BASE_R, c(1, 0), 0)
#>      [,1] [,2]
#> [1,]    1   -1
sfc_previous_point(BASE_R, c(1, 0), 90)
#>      [,1]          [,2]
#> [1,]    2 -2.449294e-16
sfc_previous_point(BASE_R, c(1, 0), 180)
#>      [,1] [,2]
#> [1,]    1    1
sfc_next_point(BASE_R, c(0, 0), 0)
#>      [,1] [,2]
#> [1,]    1    0
sfc_next_point(BASE_R, c(0, 0), 90)
#>              [,1] [,2]
#> [1,] 6.123234e-17    1
sfc_next_point(BASE_R, c(0, 0), 180)
#>      [,1]         [,2]
#> [1,]   -1 1.224647e-16
sfc_next_point(BASE_R, c(1, 0), 0)
#>      [,1] [,2]
#> [1,]    2    0
sfc_next_point(BASE_R, c(1, 0), 90)
#>      [,1] [,2]
#> [1,]    1    1
sfc_next_point(BASE_R, c(1, 0), 180)
#>      [,1]         [,2]
#> [1,]    0 1.224647e-16