Skip to contents

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:

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