def generate(self, config): C = config if C.depth <= 0: return trunk = draw.makeCylinder(C.diameter/2,C.height) self.add_geom(trunk) for i in xrange(C.branches): if i == 0: at_height = C.height else: at_height = C.height * self.picker.pick((0.5, 0.75)) location = Location() y_rotation = self.picker.pick((-math.pi/2, math.pi/2)) z_rotation = self.picker.pick((-math.pi/2, math.pi/2)) location.translate((0, 0, at_height)) location.rotate((z_rotation, (0, 0, 1))) location.rotate((y_rotation, (0, 1, 0))) height = C.height * self.picker.pick((0.25, 0.75)) diameter = C.diameter * self.picker.pick((0.25, 0.75)) self.subgen('tree', location, diameter = diameter, depth = C.depth-1, height = height)
from procodile.buildspace import Location import math a = Location() b = Location() a.rotate((math.pi / 2, (0, 0, 1))) b.rotate((math.pi * 1.5, (0, 0, 1))) print a print b b1 = Location(b) ainv = Location(a) ainv.invert() print b1.transform(ainv)