January 2020
Intermediate to advanced
532 pages
13h 31m
English
To simulate the growth of an L-System model, we can develop an LState type that keeps track of the current state of the growth. It's a simple type that just keeps a reference to the model, the current iteration of growth, and the current result. For this, consider the following code:
struct LState model current_iteration resultend
The constructor just needs to take the model as the only argument. It defaults current_iteration to 1 and defaults result to the axiom of the model, as shown here:
"Create a L-system state from a `model`."LState(model::LModel) = LState(model, 1, model.axiom)
We need a function to advance to the next stage of the growth. So, we just provide a next function:
function next(state::LState) ...
Read now
Unlock full access