metal "Quadratic curved surface sample" { /* 境界体積付き直方体 中心座標(l,m,n) 辺の長さの半分が(a,b,c) */ procedure hexgon l,m,n, a,b,c { para l,m,n; sim a,b,c; boundary sphere 0,0,0, sqrt (3) { and { plane 1,0,0, 1,0,0; plane -1,0,0, -1,0,0; plane 0,1,0, 0,1,0; plane 0,-1,0, 0,-1,0; plane 0,0,1, 0,0,1; plane 0,0,-1, 0,0,-1; } } } /* 境界体積付き円柱面 中心座標(x,y,z) 円柱面の方向(a,b,c) 半径r 高さ2×h 注意: 高さは両側にのびる。(a,b,c)方向にh、(-a,-b,-c)方向にh。 */ procedure cylb x,y,z, a,b,c, r,h { var r'=sqrt (2/3), h'=sqrt (1/3); para x,y,z; // 指定の位置まで平行移動 leverz a,b,c; // 指定の方向に向ける sim r/r',r/r',h/h'; // 指定のサイズに合わせる boundary sphere 0,0,0, 1 // 半径1の球の中に入る、体積最大の円柱面。 { and { plane 0,0,h', 0,0,1; cylind 0,0,0, 0,0,1, r'; plane 0,0,-h', 0,0,-1; } } } /* 境界体積付き円錐面 頂点座標(x,y,z) 底面の方向(a,b,c) 底面の半径r 高さh */ procedure conb x,y,z, a,b,c, r,h { para x,y,z; leverz a,b,c; sim r,r,h/2; boundary sphere 0,0,1, sqrt (3) { and { plane 0,0,2, 0,0,1; cone 0,0,0, 0,0,1, 1/2; plane 0,0,0, 0,0,-1; } } } attr base_attr= { diff 0.70,0.000; refl 0.01,90,0.1; }; attr Black= { dupri base_attr; color 0,0,0; }; attr Red= { dupri base_attr; color 1,0,0; }; attr Green= { dupri base_attr; color 0,1,0; }; attr Blue= { dupri base_attr; color 0,0,1; }; attr Yellow= { dupri base_attr; color 1,1,0; }; attr Cyan= { dupri base_attr; color 0,1,1; }; attr Magenta= { dupri base_attr; color 1,0,1; }; attr White= { dupri base_attr; color 1,1,1; }; ginit 64,64,32; box 0,0,63,63, cwhite, solid; box 0,0,31,31, cblack, solid; box 32,32,63,63, cblack, solid; cmap check, 0,0,63,63, 64,64; attr checker= { dupri Black; map check; mpla 0,0,0, 0,1,0, 1,0,0, 20,20; }; // 台(直方体) hexgon 0,-5,0, 40,5,40; // 円錐面 attr Red; conb 20,30,20, 0,-1,0, 15,30; // 円柱面 attr Yellow; cylb 0,15,-15, 0,1,0, 15,15; // 球面 attr Cyan; sphere -15,15,25, 15; view 55, 0,1,0, 0,0,0, 40,150,120; ambi 1.0, 0.400,0.400,0.400, 0.200, 0,0; inf -1,2,3, 0.267, 1.000,1.000,1.000; } TUhIE7Owuvm