def maketrunk(self, mcmap):
        '''Generate the trunk, roots, and branches in mcmap.
        '''
        height = self.height
        trunkheight = self.trunkheight
        trunkradius = self.trunkradius
        treeposition = self.pos
        starty = treeposition[1]
        midy = treeposition[1] + int(trunkheight * .382)
        topy = treeposition[1] + int(trunkheight + 0.5)
        # In this method, x and z are the position of the trunk.
        x = treeposition[0]
        z = treeposition[2]
        end_size_factor = trunkheight / height
        midrad = trunkradius * (1 - end_size_factor * .5)
        endrad = trunkradius * (1 - end_size_factor)
        if endrad < 1.0:
            endrad = 1.0
        if midrad < endrad:
            midrad = endrad
        # Make the root buttresses, if indicated
        if ROOTBUTTRESSES or SHAPE == "mangrove":
            # The start radius of the trunk should be a little smaller if we
            # are using root buttresses.
            startrad = trunkradius * .8
            # rootbases is used later in self.makeroots(...) as
            # starting locations for the roots.
            rootbases = [[x, z, startrad]]
            buttress_radius = trunkradius * 0.382
            # posradius is how far the root buttresses should be offset
            # from the trunk.
            posradius = trunkradius
            # In mangroves, the root buttresses are much more extended.
            if SHAPE == "mangrove":
                posradius *= 2.618
            num_of_buttresses = int(sqrt(trunkradius) + 3.5)
            for i in range(num_of_buttresses):
                rndang = random() * 2 * pi
                thisposradius = posradius * (0.9 + random() * .2)
                # thisx and thisz are the x and z position for the base of
                # the root buttress.
                thisx = x + int(thisposradius * sin(rndang))
                thisz = z + int(thisposradius * cos(rndang))
                # thisbuttressradius is the radius of the buttress.
                # Currently, root buttresses do not taper.
                thisbuttressradius = buttress_radius * (0.618 + random())
                if thisbuttressradius < 1.0:
                    thisbuttressradius = 1.0
                # Make the root buttress.
                self.taperedcylinder([thisx, starty, thisz], [x, midy, z],
                                     thisbuttressradius, thisbuttressradius,
                                     mcmap, WOODINFO)
                # Add this root buttress as a possible location at
                # which roots can spawn.
                rootbases += [[thisx, thisz, thisbuttressradius]]
        else:
            # If root buttresses are turned off, set the trunk radius
            # to normal size.
            startrad = trunkradius
            rootbases = [[x, z, startrad]]
        # Make the lower and upper sections of the trunk.
        self.taperedcylinder([x, starty, z], [x, midy, z], startrad, midrad,
                             mcmap, WOODINFO)
        self.taperedcylinder([x, midy, z], [x, topy, z], midrad, endrad,
                             mcmap, WOODINFO)
        #Make the branches
        self.makebranches(mcmap)
        #Make the roots, if indicated.
        if ROOTS in ["yes", "tostone", "hanging"]:
            self.makeroots(rootbases, mcmap)
        # Hollow the trunk, if specified
        # check to make sure that the trunk is large enough to be hollow
        if trunkradius > 2 and HOLLOWTRUNK:
            # wall thickness is actually the double the wall thickness
            # it is a diameter difference, not a radius difference.
            wall_thickness = (1 + trunkradius * 0.1 * random())
            if wall_thickness < 1.3:
                wall_thickness = 1.3
            base_radius = trunkradius - wall_thickness
            if base_radius < 1:
                base_radius = 1.0
            mid_radius = midrad - wall_thickness
            top_radius = endrad - wall_thickness
            # the starting x and y can be offset by up to the wall thickness.
            base_offset = int(wall_thickness)
            x_choices = [i for i in range(x - base_offset,
                                          x + base_offset + 1)]
            start_x = choice(x_choices)
            z_choices = [i for i in range(z - base_offset,
                                          z + base_offset + 1)]
            start_z = choice(z_choices)
            self.taperedcylinder([start_x, starty, start_z], [x, midy, z],
                                 base_radius, mid_radius,
                                 mcmap, TRUNKFILLINFO)
            hollow_top_y = int(topy + trunkradius + 1.5)
            self.taperedcylinder([x, midy, z], [x, hollow_top_y, z],
                                 mid_radius, top_radius,
                                 mcmap, TRUNKFILLINFO)
Generate the trunk, roots, and branches in mcmap.
        
stock-filters/Forester.py