Skip to content
Snippets Groups Projects
Commit e81e3cde authored by Hendrik Schwanekamp's avatar Hendrik Schwanekamp
Browse files

give tree a set diameter function

parent cde25bb3
No related branches found
No related tags found
No related merge requests found
import numpy as np
import TreeSpecies as ts
import TreeModel as mdl
class Tree:
......@@ -7,7 +8,20 @@ class Tree:
truncDiameter = 0.0 # tree diameter in centimeter
truncRadius = 0.0 # tree radius in centimeter
leafRadius = 0.0 # leaf radius in centimeter
leafArea = 0.0 # the leaf area of the tree
height = 0.0 # height of the tree
species = ts.null # tree species
isAlive = True # is the tree still alive?
def setDiameter(self, dia):
"""Set a new diameter for the tree and recalculate all diameter dependent properties."""
self.truncDiameter = dia
self.truncRadius = dia / 2
self.leafArea = mdl.getLeafArea(self.species.c, self.truncDiameter)
self.leafRadius = np.sqrt(self.leafArea / np.pi)
self.height = mdl.getHeight(self.truncDiameter, self.species.hmax, self.species.dmax)
def __init__(self, pos, spec, dia=0.5):
self.position = pos
self.species = spec
self.setDiameter(dia)
......@@ -24,7 +24,7 @@ class TreeSpecies:
self.trunkColor = trunkColor
null = TreeSpecies(0,0,0,0,0)
null = TreeSpecies(0,0,0,0.1,0.1)
maple = TreeSpecies(3011, 152.5, 170, 1.57, 200, 'brown', 'green')
beech = TreeSpecies(2660, 122, 150, 2.2, 300, 'brown', 'green')
fir = TreeSpecies(1830, 50, 200, 2.5, 80, 'brown', 'green')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment