def rotateTemplate(template, x=0, y=0):
    """
    Rotate template around x-axis and then around
    y-axis. Both angles must to multiples of 90.
    TODO: Add ability for multiples of 45
    """
    template = template.copy()
    for _ in xrange(0, x, 90):
        # y -> -z and z -> y
        template[..., (1, 2)] = template[..., (2, 1)]
        template[..., 2] -= 0.5
        template[..., 2] *= -1
        template[..., 2] += 0.5

    for _ in xrange(0, y, 90):
        # z -> -x and x -> z
        template[..., (0, 2)] = template[..., (2, 0)]
        template[..., 0] -= 0.5
        template[..., 0] *= -1
        template[..., 0] += 0.5
    return template

    Rotate template around x-axis and then around
    y-axis. Both angles must to multiples of 90.
    TODO: Add ability for multiples of 45
    
renderer.py