Skip to contents

Expand the curve to the next level

Usage

# S4 method for sfc_2x2
sfc_expand(p, code, flip = FALSE)

# S4 method for sfc_3x3_peano
sfc_expand(p, code = 1, flip = FALSE)

# S4 method for sfc_3x3_meander
sfc_expand(p, code, flip = FALSE)

Arguments

p

An sfc_2x2 object or other related objects.

code

Expansion code, a single integer.

flip

Whethe to flip level-1 units? The value should be a logical vector of length one or the same as the length of p.

Value

An object in the same class as the input.

Details

For the Hilbert curve and Meander curve, as long as the expansion code of the first base pattern in the sequence is determinted, the expansion codes for other base patterns in the sequence are all determined. For the Peano curve, since there is only one traverse path on any level, code is ignored.

These functions are mainly used internally.

Examples

p = sfc_2x2("I", 11)
sfc_expand(p, 2) # I|211
#> An sfc_2x2 object.
#>   Increase mode: 2 x 2
#>   Level: 3
#>   Expansion rule: 2x2 
#> 
#> A sequence of 64 base patterns.
#>   L(0)R(90)R(0)L(270)      L(0)R(90)R(0)I(270)
#>   I(270)R(270)R(180)L(90)  I(180)L(180)L(270)R(0)
#>   .... other 4 lines ....
#>   R(90)L(0)L(90)I(180)     L(180)R(270)R(180)I(90)
#>   I(90)R(90)R(0)L(270)     L(0)R(90)R(0)L(270)
#> 
#> Seed: A sequence of 1 base pattern.
#>   I(0)  
p = sfc_3x3_peano("I", 11)
sfc_expand(p, 2) # I|211
#> An sfc_3x3_peano object.
#>   Increase mode: 3 x 3
#>   Level: 3
#>   Expansion rule: 3x3 Peano 
#> 
#> A sequence of 729 base patterns.
#>   I(0)J(0)R(0)R(270)  I(180)L(180)L(270)J(0)
#>   I(0)J(0)I(0)L(0)    L(90)J(180)R(180)R(90)
#>   .... other 88 lines ....
#>   I(0)J(0)R(0)R(270)  I(180)L(180)L(270)J(0)
#>   I(0)                
#> 
#> Seed: A sequence of 1 base pattern.
#>   I(0)  
p = sfc_3x3_meander("I", 11)
sfc_expand(p, 2) # I|211
#> An sfc_3x3_meander object.
#>   Increase mode: 3 x 3
#>   Level: 3
#>   Expansion rule: 3x3 Meander 
#> 
#> A sequence of 729 base patterns.
#>   L(0)I(90)R(90)I(0)  R(0)R(270)L(180)L(270)
#>   I(0)L(0)I(90)R(90)  I(0)R(0)R(270)L(180)
#>   .... other 88 lines ....
#>   L(0)I(90)R(90)I(0)  R(0)R(270)L(180)L(270)
#>   I(0)                
#> 
#> Seed: A sequence of 1 base pattern.
#>   I(0)