Level-1 unit in the Peano curve and Meander curve
Usage
# S4 method for sfc_3x3_peano
level1_unit_orientation(p)
# S4 method for sfc_3x3_peano
change_level1_unit_orientation(p, to = c("horizontal", "vertical"))
# S4 method for sfc_3x3_meander
level1_unit_orientation(p)
# S4 method for sfc_3x3_meander
change_level1_unit_orientation(p, to = c("forward", "backward"))Arguments
- p
For
level1_unit_orientation(), it is ansfc_3x3_peanoorsfc_3x3_meanderunit on level 1. Forchange_level1_unit_orientation(), it is a normalsfc_3x3_peanoorsfc_3x3_meanderobject.- to
A string of "vertical/horizontal" (on the
sfc_3x3_peanoobject) or "forward/backward" (on thesfc_3x3_meanderobject).
Value
level1_unit_orientation() returns "verticalhorizontal" (on the sfc_3x3_peano object) or "forward/backward" (on the sfc_3x3_meander object).
change_level1_unit_orientation() returns an sfc_3x3_peano or sfc_3x3_meander object.
Details
"vertical" and "horizontal" correspond to the direction of the "long segments" in a Peano curve (see Examples).
level1_unit_orientation() is normally used inside sfc_apply(). change_level1_unit_orientation()
changes all level-1 units of a Peano curve or a Meander curve simultaneously.
Examples
p = sfc_3x3_peano("I", 111)
# the first level-1 unit
level1_unit_orientation(p[1:9, TRUE])
#> [1] "vertical"
# the fourth level-1 unit
level1_unit_orientation(p[1:9 + 27, TRUE])
#> [1] "horizontal"
p2 = change_level1_unit_orientation(p, "horizontal")
p3 = change_level1_unit_orientation(p, "vertical")
draw_multiple_curves(p, p2, p3,
title = c("original", "all horizontal", "all vertical"), nrow = 1)
# by default, orientations of all level-1 units in Meander curve are forward
p = sfc_3x3_meander("I", 111)
level1_unit_orientation(p[1:9, TRUE])
#> [1] "forward"
p2 = change_level1_unit_orientation(p, "backward")
draw_multiple_curves(p, p2,
title = c("all forward", "all backward"), nrow = 1)