% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sfc_rules.R
\name{sfc_rules}
\alias{sfc_rules}
\title{Constructor of the sfc_rules class}
\usage{
sfc_rules(rules, bases, flip = list(), name = "sfc_rules")
}
\arguments{
\item{rules}{A list of rules.}

\item{bases}{A list of base patterns.}

\item{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`.}

\item{name}{A self-defined string.}
}
\value{
An `sfc_rules` object.
}
\description{
Constructor of the sfc_rules class
}
\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 \url{https://github.com/jokergoo/sfcurve/blob/master/R/zz_global.R} to see how these pre-defined rules are constructed.
}
