
def O (0,0,0) % orig
def J [0,1,0] % rotation axis


def tet1 {
    def p0 (0,3)
    def p1 (2.5,0)
    def N 3
    def seg_rot rotate(360 / N, [J])
    % draw the tetrahedron by rotating a line about the J axis
    sweep[fill=black!20] { N<>, [[seg_rot]] }
    line[cull=false,fill=blue!20,fill opacity=0.5](p0)(p1)
    def p03 (p0)
    def p01 (p1)
    def p02 (p1) then [[seg_rot]]
    def p00 (p1) then [[seg_rot]]^2
    dots(p00)(p01)(p02)(p03)
    special|\fill[black,font=\footnotesize]
                #1 node [left] {0}
                #2 node [below] {1}
                #3 node [right] {2}
                #4 node [above] {3};|
    (p00)(p01)(p02)(p03)
    
}

def tet2 {
   def p0 (0,3)
    def p1 (2.5,0)
    def N 3
    def seg_rot rotate(360 / N, [J])
    % draw the tetrahedron by rotating a line about the J axis
    sweep[fill=black!20] { N<>, [[seg_rot]] }
    line[cull=false,fill=blue!20,fill opacity=0.5](p0)(p1)
    def p03 (p0)
    def p01 (p1)
    def p02 (p1) then [[seg_rot]]
    def p00 (p1) then [[seg_rot]]^2
    def mid1 ((p00)-(O)+(p01)-(O)+(p03)-(O))/3+(O)
    def mid2 ((p01)-(O)+(p02)-(O)+(p03)-(O))/3+(O)
    def mid3 ((p00)-(O)+(p02)-(O)+(p03)-(O))/3+(O)
    def mid4 ((p00)-(O)+(p01)-(O)+(p02)-(O))/3+(O)
    dots(p00)(p01)(p02)(p03)(mid1)(mid2)(mid3)(mid4)
    special|\fill[black,font=\footnotesize]
                #1 node [left] {0}
                #2 node [below] {1}
                #3 node [right] {2}
                #4 node [above] {3}
                #5 node [left] {4}
                #6 node [right] {5}
                #7 node [above] {7}
                #8 node [above] {6};|
    (p00)(p01)(p02)(p03)(mid1)(mid2)(mid3)(mid4)
}

def tet3 {
    def p0 (0,3)
    def p1 (2.5,0)
    def N 3
    def seg_rot rotate(360 / N, [J])
    % draw the tetrahedron by rotating a line about the J axis
    sweep[fill=black!20] { N<>, [[seg_rot]] }
    line[cull=false,fill=blue!20,fill opacity=0.5](p0)(p1)
    def p03 (p0)
    def p01 (p1)
    def p02 (p1) then [[seg_rot]]
    def p00 (p1) then [[seg_rot]]^2
    def mid1 ((p00)-(O)+(p01)-(O))/2+(O)
    def mid2 ((p01)-(O)+(p02)-(O))/2+(O)
    def mid3 ((p02)-(O)+(p00)-(O))/2+(O)
    def mid4 ((p00)-(O)+(p03)-(O))/2+(O)
    def mid5 ((p01)-(O)+(p03)-(O))/2+(O)
    def mid6 ((p02)-(O)+(p03)-(O))/2+(O)
    dots(p00)(p01)(p02)(p03)(mid1)(mid2)(mid3)(mid4)(mid5)(mid6)
    special|\fill[black,font=\footnotesize]
                #1 node [left] {0}
                #2 node [below] {1}
                #3 node [right] {2}
                #4 node [above] {3}
                #5 node [below] {4}
                #6 node [below] {5}
                #7 node [above] {6}
                #8 node [left] {7}
                #9 node [left] {8}
                #10 node [right] {9};|
    (p00)(p01)(p02)(p03)(mid1)(mid2)(mid3)(mid4)(mid5)(mid6)
    
}

def tet4 {
    def p0 (0,3)
    def p1 (2.5,0)
    def N 3
    def seg_rot rotate(360 / N, [J])
    % draw the tetrahedron by rotating a line about the J axis
    sweep[fill=black!20] { N<>, [[seg_rot]] }
    line[cull=false,fill=blue!20,fill opacity=0.5](p0)(p1)
    def p03 (p0)
    def p01 (p1)
    def p02 (p1) then [[seg_rot]]
    def p00 (p1) then [[seg_rot]]^2
    def mid1 ((p00)-(O)+(p01)-(O))/2+(O)
    def mid2 ((p01)-(O)+(p02)-(O))/2+(O)
    def mid3 ((p02)-(O)+(p00)-(O))/2+(O)
    def mid4 ((p00)-(O)+(p03)-(O))/2+(O)
    def mid5 ((p01)-(O)+(p03)-(O))/2+(O)
    def mid6 ((p02)-(O)+(p03)-(O))/2+(O)
    special|\fill[black,font=\footnotesize]
                #1 node [below] {0}
                #2 node [below] {1}
                #3 node [above] {2}
                #4 node [left] {3}
                #5 node [right] {4}
                #6 node [right] {5};|
    (mid1)(mid2)(mid3)(mid4)(mid5)(mid6)
    
}

def tet5 {
    def p0 (0,3)
    def p1 (2.5,0)
    def N 3
    def seg_rot rotate(360 / N, [J])
    % draw the tetrahedron by rotating a line about the J axis
    sweep[fill=black!20] { N<>, [[seg_rot]] }
    line[cull=false,fill=blue!20,fill opacity=0.5](p0)(p1)
    def p03 (p0)
    def p01 (p1)
    def p02 (p1) then [[seg_rot]]
    def p00 (p1) then [[seg_rot]]^2
    def mid1 ((p00)-(O)+(p01)-(O)+(p03)-(O))/3+(O)
    def mid2 ((p01)-(O)+(p02)-(O)+(p03)-(O))/3+(O)
    def mid3 ((p00)-(O)+(p02)-(O)+(p03)-(O))/3+(O)
    def mid4 ((p00)-(O)+(p01)-(O)+(p02)-(O))/3+(O)
    special|\fill[black,font=\footnotesize]
                #1 node [] {0}
                #2 node [] {1}
                #3 node [] {2}
                #4 node [] {3};|
    (mid1)(mid2)(mid3)(mid4)
    
}

put { view((10,4,2)) } {tet5}

global { language tikz }

