|
> No.1643[元記事へ]
続き
EXTERNAL SUB OBJ(#1,X,Y,Z,L)
CALL TUBE(#1,X-L/2,Y,Z,X+L/2,Y,Z,L/4)
CALL TUBE(#1,X,Y+L/2,Z,X,Y-L/2,Z,L/4)
CALL TUBE(#1,X,Y,Z-L/2,X,Y,Z+L/2,L/4)
CALL OCTAHEDRON(#1,X,Y,Z,L,L,L)
END SUB
EXTERNAL SUB TUBE(#1,X0,Y0,Z0,X1,Y1,Z1,LL) !'角柱(蓋あり)
DIM XX(4),YY(4),ZZ(4)
LET X=X1-X0 !'線分(X0,Y0,Z0)-(X1,Y1,Z1)に垂直な適当なベクトル(A,B,C)
LET Y=Y1-Y0
LET Z=Z1-Z0
LET A=1
LET B=1
LET C=1
IF X<>0 THEN !'内積0よりX*A+Y*B+Z*C=0
LET A=(-B*Y-C*Z)/X
ELSEIF Y<>0 THEN
LET B=(-A*X-C*Z)/Y
ELSEIF Z<>0 THEN
LET C=(-A*X-B*Y)/Z
END IF
LET SS=SQR(A*A+B*B+C*C)
LET A=A/SS !'単位ベクトル
LET B=B/SS
LET C=C/SS
LET TX=A*LL
LET TY=B*LL
LET TZ=C*LL
FOR K=0 TO 3
CALL ROTATE(TX,TY,TZ,X,Y,Z,K*90,XA,YA,ZA)
CALL ROTATE(TX,TY,TZ,X,Y,Z,(K+1)*90,XB,YB,ZB)
PRINT #1:"0"
PRINT #1:"3DFACE"
PRINT #1:"8"
PRINT #1:"LAYER1"
PRINT #1:"62"
PRINT #1:"1"
PRINT #1:"10"
PRINT #1:XA+X0
PRINT #1:"20"
PRINT #1:YA+Y0
PRINT #1:"30"
PRINT #1:ZA+Z0
PRINT #1:"11"
PRINT #1:XB+X0
PRINT #1:"21"
PRINT #1:YB+Y0
PRINT #1:"31"
PRINT #1:ZB+Z0
PRINT #1:"12"
PRINT #1:XB+X1
PRINT #1:"22"
PRINT #1:YB+Y1
PRINT #1:"32"
PRINT #1:ZB+Z1
PRINT #1:"13"
PRINT #1:XA+X1
PRINT #1:"23"
PRINT #1:YA+Y1
PRINT #1:"33"
PRINT #1:ZA+Z1
LET XX(K+1)=XA !'(追加部分)
LET YY(K+1)=YA
LET ZZ(K+1)=ZA
NEXT K
PRINT #1:"0" !'蓋(追加部分)
PRINT #1:"3DFACE"
PRINT #1:"8"
PRINT #1:"LAYER1"
PRINT #1:"62"
PRINT #1:"1"
PRINT #1:"10"
PRINT #1:XX(1)+X1
PRINT #1:"20"
PRINT #1:YY(1)+Y1
PRINT #1:"30"
PRINT #1:ZZ(1)+Z1
PRINT #1:"11"
PRINT #1:XX(2)+X1
PRINT #1:"21"
PRINT #1:YY(2)+Y1
PRINT #1:"31"
PRINT #1:ZZ(2)+Z1
PRINT #1:"12"
PRINT #1:XX(3)+X1
PRINT #1:"22"
PRINT #1:YY(3)+Y1
PRINT #1:"32"
PRINT #1:ZZ(3)+Z1
PRINT #1:"13"
PRINT #1:XX(4)+X1
PRINT #1:"23"
PRINT #1:YY(4)+Y1
PRINT #1:"33"
PRINT #1:ZZ(4)+Z1
PRINT #1:"0"
PRINT #1:"3DFACE"
PRINT #1:"8"
PRINT #1:"LAYER1"
PRINT #1:"62"
PRINT #1:"1"
PRINT #1:"10"
PRINT #1:XX(4)+X0
PRINT #1:"20"
PRINT #1:YY(4)+Y0
PRINT #1:"30"
PRINT #1:ZZ(4)+Z0
PRINT #1:"11"
PRINT #1:XX(3)+X0
PRINT #1:"21"
PRINT #1:YY(3)+Y0
PRINT #1:"31"
PRINT #1:ZZ(3)+Z0
PRINT #1:"12"
PRINT #1:XX(2)+X0
PRINT #1:"22"
PRINT #1:YY(2)+Y0
PRINT #1:"32"
PRINT #1:ZZ(2)+Z0
PRINT #1:"13"
PRINT #1:XX(1)+X0
PRINT #1:"23"
PRINT #1:YY(1)+Y0
PRINT #1:"33"
PRINT #1:ZZ(1)+Z0
END SUB
以下省略
EXTERNAL SUB ROTATE(XX,YY,ZZ,X0,Y0,Z0,TH,NX,NY,NZ) !'任意軸回転(ロドリグの公式)
END SUB
|
|