複雜的金字塔

貼吧有人想做這個:

可以看出他想要的是一組四棱錐。很規整嘛,決定用三角塊拼起來實現,代碼如下:

module item(x1,x2,y1,y2,h){
    xa=x1>x2?x1:x2;
    xi=x2<x1?x2:x1;
    ya=y1>y2?y1:y2;
    yi=y2<y1?y2:y1;
    polyhedron(
        points=[ 
            [xa,ya,0],
            [xa,yi,0],
            [xi,yi,0],
            [xi,ya,0], // the four points at base
            [0,0,h] // the apex point 
        ],
        faces=[ 
            [0,1,4],[1,2,4],[2,3,4],[3,0,4],// each triangle side
            [1,0,3],[2,1,3] // two triangles for square base
        ]
    );
}
item(-10,-2,-10,-2,10);
item(-10,-2, 10, 2,10);
item( 10, 2,-10,-2,10);
item( 10, 2, 10, 2,10);

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章