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

% Wedge with 6 nodes
def wedge1 {
    def p0 (2.5,3)
    def p1 (2.5,0)
    def N 3
    def seg_rot rotate(360 / N, [J])
    % draw the wedge 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)
    % define nodal points
    def p04 (p0)
    def p01 (p1)
    def p05 (p0) then [[seg_rot]]
    def p03 (p0) then [[seg_rot]]^2
    def p02 (p1) then [[seg_rot]]
    def p00 (p1) then [[seg_rot]]^2
    dots(p00)(p01)(p02)(p03)(p04)(p05)
    % label nodal points
    special|\fill[black,font=\footnotesize]
                #1 node [below] {0}
                #2 node [below] {1}
                #3 node [below] {2}
                #4 node [above] {3}
                #5 node [above] {4}
                #6 node [above] {5};|
    (p00)(p01)(p02)(p03)(p04)(p05)
}

% Wedge with 15 nodes
def wedge2 {
    def p0 (2.5,3)
    def p1 (2.5,0)
    def N 3
    def seg_rot rotate(360 / N, [J])
    % draw the wedge 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)
    % define nodal points
    def p04 (p0)
    def p01 (p1)
    def p05 (p0) then [[seg_rot]]
    def p03 (p0) then [[seg_rot]]^2
    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)+(p04)-(O))/2+(O)
    def mid6 ((p02)-(O)+(p05)-(O))/2+(O)
    def mid7 ((p03)-(O)+(p04)-(O))/2+(O)
    def mid8 ((p04)-(O)+(p05)-(O))/2+(O)
    def mid9 ((p05)-(O)+(p03)-(O))/2+(O)
    dots(p00)(p01)(p02)(p03)(p04)(p05)(mid1)(mid2)(mid3)(mid4)(mid5)(mid6)(mid7)(mid8)(mid9)
    % label nodal points
    special|\fill[black,font=\footnotesize]
                #1 node [below] {0}
                #2 node [below] {1}
                #3 node [below] {2}
                #4 node [above] {3}
                #5 node [above] {4}
                #6 node [above] {5}
                #7 node [below] {6}
                #8 node [below] {7}
                #9 node [above] {8}
                #10 node [left] {9}
                #11 node [right] {10}
                #12 node [right] {11}
                #13 node [above] {12}
                #14 node [above] {13}
                #15 node [above] {14};|
    (p00)(p01)(p02)(p03)(p04)(p05)(mid1)(mid2)(mid3)(mid4)(mid5)(mid6)(mid7)(mid8)(mid9)
}

% Wedge with 18 nodes
def wedge3 {
    def p0 (2.5,3)
    def p1 (2.5,0)
    def N 3
    def seg_rot rotate(360 / N, [J])
    % draw the wedge 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)
   % define nodal points
    def p04 (p0)
    def p01 (p1)
    def p05 (p0) then [[seg_rot]]
    def p03 (p0) then [[seg_rot]]^2
    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)+(p04)-(O))/2+(O)
    def mid6 ((p02)-(O)+(p05)-(O))/2+(O)
    def mid7 ((p03)-(O)+(p04)-(O))/2+(O)
    def mid8 ((p04)-(O)+(p05)-(O))/2+(O)
    def mid9 ((p05)-(O)+(p03)-(O))/2+(O)
    def mid10 ((p00)-(O)+(p01)-(O)+(p04)-(O)+(p03)-(O))/4+(O)
    def mid11 ((p01)-(O)+(p02)-(O)+(p05)-(O)+(p04)-(O))/4+(O)
    def mid12 ((p02)-(O)+(p00)-(O)+(p03)-(O)+(p05)-(O))/4+(O)
    dots(p00)(p01)(p02)(p03)(p04)(p05)(mid1)(mid2)(mid3)(mid4)(mid5)(mid6)(mid7)(mid8)(mid9)(mid10)(mid11)(mid12)
    % label nodal points
    special|\fill[black,font=\footnotesize]
                #1 node [below] {0}
                #2 node [below] {1}
                #3 node [below] {2}
                #4 node [above] {3}
                #5 node [above] {4}
                #6 node [above] {5}
                #7 node [below] {6}
                #8 node [below] {7}
                #9 node [above] {8}
                #10 node [left] {9}
                #11 node [right] {10}
                #12 node [right] {11}
                #13 node [above] {12}
                #14 node [above] {13}
                #15 node [above] {14}
                #16 node [above] {15}
                #17 node [above] {16}
                #18 node [below] {17};|
    (p00)(p01)(p02)(p03)(p04)(p05)(mid1)(mid2)(mid3)(mid4)(mid5)(mid6)(mid7)(mid8)(mid9)(mid10)(mid11)(mid12)
}

% Wedge edge numbering
def wedge4 {
    def p0 (2.5,3)
    def p1 (2.5,0)
    def N 3
    def seg_rot rotate(360 / N, [J])
    % draw the wedge 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 p04 (p0)
    def p01 (p1)
    def p05 (p0) then [[seg_rot]]
    def p03 (p0) then [[seg_rot]]^2
    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 mid7 ((p00)-(O)+(p03)-(O))/2+(O)
    def mid8 ((p01)-(O)+(p04)-(O))/2+(O)
    def mid9 ((p02)-(O)+(p05)-(O))/2+(O)
    def mid4 ((p03)-(O)+(p04)-(O))/2+(O)
    def mid5 ((p04)-(O)+(p05)-(O))/2+(O)
    def mid6 ((p05)-(O)+(p03)-(O))/2+(O)
    special|\fill[black,font=\footnotesize]
                #1 node [below] {0}
                #2 node [below] {1}
                #3 node [above] {2}
                #4 node [above] {3}
                #5 node [above] {4}
                #6 node [above] {5}
                #7 node [left] {6}
                #8 node [right] {7}
                #9 node [right] {8};|
    (mid1)(mid2)(mid3)(mid4)(mid5)(mid6)(mid7)(mid8)(mid9)
}

% Wedge face numbering
def wedge5 {
    def p0 (2.5,3)
    def p1 (2.5,0)
    def N 3
    def seg_rot rotate(360 / N, [J])
    % draw the wedge 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 p04 (p0)
    def p01 (p1)
    def p05 (p0) then [[seg_rot]]
    def p03 (p0) then [[seg_rot]]^2
    def p02 (p1) then [[seg_rot]]
    def p00 (p1) then [[seg_rot]]^2
    def mid1 ((p00)-(O)+(p01)-(O)+(p04)-(O)+(p03)-(O))/4+(O)
    def mid2 ((p01)-(O)+(p02)-(O)+(p05)-(O)+(p04)-(O))/4+(O)
    def mid3 ((p00)-(O)+(p03)-(O)+(p05)-(O)+(p02)-(O))/4+(O)
    def mid4 ((p00)-(O)+(p01)-(O)+(p02)-(O))/3+(O)
    def mid5 ((p03)-(O)+(p04)-(O)+(p05)-(O))/3+(O)
    special|\fill[black,font=\footnotesize]
                #1 node [] {0}
                #2 node [] {1}
                #3 node [] {2}
                #4 node [] {3}
                #5 node [] {4};|
    (mid1)(mid2)(mid3)(mid4)(mid5)
}

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

global { language tikz }

