germinate: Germinate a seed.

Description Usage Arguments Value See Also Examples

Description

Observe the miracle of life as your seed germinates and spews forth a glorious tree.

Usage

1
2
germinate(x, angle = 20, trunk.width = 20, left = "0", right = "1",
  plot = TRUE, ...)

Arguments

x

Either a seed object returned by seed, or a named list containing:

trunk.height

Exactly how glorious will this tree be?

branches

A binary coded vector of addresses of branches to be included. Branches can branch to the left or the right from the end of the trunk, or from the end of another branch included in branches. Elements of branches may only contain the characters given in args left and right, and all parent branches of each element must also be provided. E.g. if left and right are '0' and '1', respectively, then '0' is the first branch to the left stemming from the top of the trunk, while '1' is the first branch to the right, stemming from the top of the trunk; '01' would be a branch forking to the right from the end of the first branch that forked left off the trunk.

lengths

A vector of branch lengths corresponding to the elements of branches. Should be the same length as branches.

angle

The angle of branches relative to their parent branch (or relative to the trunk). This angle is negated for left-pointing branches.

trunk.width

The line width of the trunk. Widths are then scaled down for successive child branches, to a minimum of 1.

left

The character used to represent left-turning branches in the branches vector (default is '0'). Must not be 'Y'.

right

The character used to represent right-turning branches in the branches vector (default is '1'). Must not be 'Y'.

plot

Should the tree be plotted? (logical).

...

Further arguments to plot.plant.

Value

a plant object, which is a data.frame comprising branch addresses, depths, lengths, angles, base coordinates, and tip coordinates.

See Also

seed foliate prune

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Motivating example from http://stackoverflow.com/q/28163979/489704.
# Pass a named list (describing the seed) to germinate.
germinate(list(trunk.height=32, 
               branches=c('0', '1', '00', '01', '010', '011'), 
               lengths=c(21, 19, 5, 12, 6, 2)), 
          left='0', right='1', angle=40)
          
# Or simulate a seed and pass it directly to germinate
s <- seed(50, 10, min.branch.length=0, max.branch.length=5, 
             min.trunk.height=3, max.trunk.height=5)
g <- germinate(s, trunk.width=15)

# Additional realism (hard to imagine!) is possible by actually plotting the 
#  trees in a browny colour...
plot(g, trunk.width=15, col='peachpuff4')
# (Pro-tip: see ?foliate for more realism)

# In addition to the mighty oaks above, you might also like to germinate a 
#  clumpy grassy-type thing
s <- seed(60, 15, min.branch.length=0, max.branch.length=5, 
          min.trunk.height=0, max.trunk.height=0)
g <- germinate(s, angle=5, trunk.width=10)

johnbaums/trees documentation built on May 19, 2019, 3:03 p.m.