def makebranches(self, mcmap):
        '''Generate the branches and enter them in mcmap.
        '''
        treeposition = self.pos
        height = self.height
        topy = treeposition[1] + int(self.trunkheight + 0.5)
        # endrad is the base radius of the branches at the trunk
        endrad = self.trunkradius * (1 - self.trunkheight / height)
        if endrad < 1.0:
            endrad = 1.0
        for coord in self.foliage_cords:
            dist = (sqrt(float(coord[0] - treeposition[0]) ** 2 +
                         float(coord[2] - treeposition[2]) ** 2))
            ydist = coord[1] - treeposition[1]
            # value is a magic number that weights the probability
            # of generating branches properly so that
            # you get enough on small trees, but not too many
            # on larger trees.
            # Very difficult to get right... do not touch!
            value = (self.branchdensity * 220 * height) / ((ydist + dist) ** 3)
            if value < random():
                continue

            posy = coord[1]
            slope = self.branchslope + (0.5 - random()) * .16
            if coord[1] - dist * slope > topy:
                # Another random rejection, for branches between
                # the top of the trunk and the crown of the tree
                threshhold = 1 / float(height)
                if random() < threshhold:
                    continue
                branchy = topy
                basesize = endrad
            else:
                branchy = posy - dist * slope
                basesize = (endrad + (self.trunkradius - endrad) *
                            (topy - branchy) / self.trunkheight)
            startsize = (basesize * (1 + random()) * .618 *
                         (dist / height) ** 0.618)
            rndr = sqrt(random()) * basesize * 0.618
            rndang = random() * 2 * pi
            rndx = int(rndr * sin(rndang) + 0.5)
            rndz = int(rndr * cos(rndang) + 0.5)
            startcoord = [treeposition[0] + rndx,
                          int(branchy),
                          treeposition[2] + rndz]
            if startsize < 1.0:
                startsize = 1.0
            endsize = 1.0
            self.taperedcylinder(startcoord, coord, startsize, endsize,
                                 mcmap, WOODINFO)
Generate the branches and enter them in mcmap.
        
stock-filters/Forester.py