sfc_rules: Constructor of the sfc_rules class

View source: R/sfc_rules.R

sfc_rulesR Documentation

Constructor of the sfc_rules class

Description

Constructor of the sfc_rules class

Usage

sfc_rules(rules, bases, flip = list(), name = "sfc_rules")

Arguments

rules

A list of rules.

bases

A list of base patterns.

flip

A list of rules. They are "flipped" version of 'rules'. The value can also simply be 'TRUE', then the flipped version is automatically generated from 'rules'.

name

A self-defined string.

Details

It is mainly used internally.

'rules' is a two-level list. It is in a format of 'rules[[ base ]][[ expansion_code ]] = sfc_unit()'. In the following example where we define the expansion rules for the 2x2 curve:

“' UNIVERSE_2x2 = c("I", "R", "L", "U", "B", "D", "P", "Q", "C") RULES_2x2 = list() RULES_2x2[["I"]][[1]] = sfc_unit(c("R", "L", "L", "R"), rot = 0, universe = UNIVERSE_2x2) “'

'I' is the level-0 base pattern, '[[1]]' corresponds to the first form of expansion to level-1, and the value assigned is a ['sfc_unit()'] object which is basically a list of base patterns.

Then we also need to provide the base patterns which define how to extend the curve. The list of base patterns is assigned to the 'bases' argument. In the same example, we set 'bases' as:

“' list("I" = BASE_I, "R" = BASE_R, "L" = BASE_L, "U" = BASE_U, ...) “'

where e.g. ['BASE_I'] is a pre-defined base pattern in the ['sfc_base'] class.

There are the following pre-defined rules:

- ['SFC_RULES_2x2'] - ['SFC_RULES_3x3_PEANO'] - ['SFC_RULES_3x3_MEANDER'] - ['SFC_RULES_3x3_COMBINED'] - ['SFC_RULES_4x4_MEANDER_1'] - ['SFC_RULES_4x4_MEANDER_2']

Check https://github.com/jokergoo/sfcurve/blob/master/R/zz_global.R to see how these pre-defined rules are constructed.

Value

An 'sfc_rules' object.


sfcurve documentation built on April 10, 2026, 5:06 p.m.