
def frustum {
    def C (0,-5,0)
    def p1 (-1,0,-1)
    def p2 ( 1,0,-1)
    def p3 ( 1,0, 1)
    def p4 (-1,0, 1)

    def pp1(-3, 10, -3)
    def pp2( 3, 10, -3)
    def pp3( 3, 10,  3)
    def pp4(-3, 10,  3)

    def t11(-1.6,5.5,0.4)
    def t12(0.6,6.2,1.3)
    def t13(-0.2,5.8,-0.4)

    def t21(-2.8,3,2.8)
    def t22(-1.9,3,2.8)
    def t23(-2.8,3,1.9)

    def t31(-2,8.2,0.6)
    def t32(-4,6.4,2)
    def t33(-1.2,5.7,0.7)

    def t41(0.8,7.5,3.1)
    def t42(3.1,7.5,3.1)
    def t43(3.1,7.5,0.8)

    polygon[fill=lightgray, cull=false, fill opacity=0.8](p1)(p2)(p3)(p4)
    polygon[fill=lightgray, cull=false, fill opacity=0.8](pp1)(pp2)(pp3)(pp4)

    polygon[fill=lightgray, cull=false, fill opacity=0.8](p1)(p2)(pp2)(pp1)
    polygon[fill=lightgray, cull=false, fill opacity=0.8](p2)(p3)(pp3)(pp2)
    polygon[fill=lightgray, cull=false, fill opacity=0.8](p3)(p4)(pp4)(pp3)
    polygon[fill=lightgray, cull=false, fill opacity=0.8](p4)(p1)(pp1)(pp4)

    polygon[fill=blue, cull=false, fill opacity=1](t11)(t12)(t13)
    polygon[fill=magenta, cull=false, fill opacity=1](t21)(t22)(t23)
    polygon[fill=green, cull=false, fill opacity=1](t31)(t32)(t33)
    polygon[fill=red, cull=false, fill opacity=1](t41)(t42)(t43)

    % line[color=red](0,0,0)(5,0,0)
    % line[color=green](0,0,0)(0,5,0)
    % line[color=blue](0,0,0)(0,0,5)

    line[style=dashed](C)(p1)
    line[style=dashed](C)(p2)
    line[style=dashed](C)(p3)
    line[style=dashed](C)(p4)
}

put { rotate(-90, (0,0,0), [1,0,0]) then rotate(-45, (0,0,0), [0,1,0]) then rotate(30,(0,0,0),[1,0,0]) then scale([0.7,0.7,0.7])} {frustum}

global {
    language tikz
}
