不等式の領域

 投稿者:しばっち  投稿日:2011年 8月14日(日)23時19分44秒
  !'ボクセル表現(VOXEL)
INPUT  PROMPT "MODE(1-6)=":MODE
FOR I=1 TO MODE
   READ R,N  !'(要)調整
NEXT I
DATA 1,100
DATA 2,80
DATA 2,80
DATA 2,80
DATA 2,80
DATA 2,80
FILE GETSAVENAME F$,"dxfファイル|*.dxf"
IF F$="" THEN STOP
IF POS(UCASE$(F$),".DXF")=0 THEN LET F$=F$ & ".dxf"
OPEN #1:NAME F$
ERASE #1
PRINT #1:"0"
PRINT #1:"SECTION"
PRINT #1:"2"
PRINT #1:"ENTITIES"
FOR Y=-R TO R STEP 2*R/N
   FOR Z=-R TO R STEP 2*R/N
      FOR X=-R TO R STEP 2*R/N
         IF FUNC(MODE,X,Y,Z)<0 THEN CALL CUBE(#1,X,Y,Z,2*R/N)
      NEXT X
   NEXT Z
NEXT Y
PRINT #1:"0"
PRINT #1:"ENDSEC"
PRINT #1:"0"
PRINT #1:"EOF"
CLOSE #1
END

EXTERNAL  FUNCTION FUNC(MODE,X,Y,Z)
SELECT CASE MODE
CASE 1
!'楕円体
   LET FUNC=ELLIPSOID(X,Y,Z,.2,.3,.1)
CASE 2
!'トーラス
   LET FUNC=TORUS(X,Y,Z,1.2,.3)
CASE 3
!'トーラス(3連)
   LET FUNC=TORUS(2*X,Y,Z,1.2,.3)*TORUS(2*Z,X,Y,1.2,.3)*TORUS(2*Y,Z,X,1.2,.3)
CASE 4
!'宇宙ステーション
   LET FUNC=ELLIPSOID(X,Y,Z,.8,.2,.2)*ELLIPSOID(X,Y,Z,.2,.8,.2)*ELLIPSOID(X,Y,Z,.2,.2,.8)*TORUS(X,Y,Z,.9,.2)
CASE 5
!'ハート
   LET FUNC=(2*X^2+Y^2+Z^2-1)^3-(1/10)*X^2*Z^3-Y^2*Z^3
CASE 6
!'格子
   LET FUNC=(TAN(3*X)^2+TAN(3*Y)^2-.1)*(TAN(3*Y)^2+TAN(3*Z)^2-.1)*(TAN(3*Z)^2+TAN(3*X)^2-.1)
END SELECT
END FUNCTION

EXTERNAL  FUNCTION TORUS(X,Y,Z,RR,R)
LET TORUS=X*X+Y*Y+Z*Z-2*RR*SQR(X*X+Y*Y)+RR*RR-R*R
END FUNCTION

EXTERNAL  FUNCTION ELLIPSOID(X,Y,Z,A,B,C)
LET ELLIPSOID=(X/A)^2+(Y/B)^2+(Z/C)^2-1
END FUNCTION

EXTERNAL  SUB CUBE(#1,X,Y,Z,L)
PRINT #1:"0"
PRINT #1:"3DFACE"
PRINT #1:"8"
PRINT #1:"LAYER1"
PRINT #1:"62"
PRINT #1:"1"
PRINT #1:"10"
PRINT #1:X-L/2
PRINT #1:"20"
PRINT #1:Y+L/2
PRINT #1:"30"
PRINT #1:Z-L/2
PRINT #1:"11"
PRINT #1:X+L/2
PRINT #1:"21"
PRINT #1:Y+L/2
PRINT #1:"31"
PRINT #1:Z-L/2
PRINT #1:"12"
PRINT #1:X+L/2
PRINT #1:"22"
PRINT #1:Y+L/2
PRINT #1:"32"
PRINT #1:Z+L/2
PRINT #1:"13"
PRINT #1:X-L/2
PRINT #1:"23"
PRINT #1:Y+L/2
PRINT #1:"33"
PRINT #1:Z+L/2
PRINT #1:"0"
PRINT #1:"3DFACE"
PRINT #1:"8"
PRINT #1:"LAYER1"
PRINT #1:"62"
PRINT #1:"1"
PRINT #1:"10"
PRINT #1:X-L/2
PRINT #1:"20"
PRINT #1:Y+L/2
PRINT #1:"30"
PRINT #1:Z+L/2
PRINT #1:"11"
PRINT #1:X+L/2
PRINT #1:"21"
PRINT #1:Y+L/2
PRINT #1:"31"
PRINT #1:Z+L/2
PRINT #1:"12"
PRINT #1:X+L/2
PRINT #1:"22"
PRINT #1:Y-L/2
PRINT #1:"32"
PRINT #1:Z+L/2
PRINT #1:"13"
PRINT #1:X-L/2
PRINT #1:"23"
PRINT #1:Y-L/2
PRINT #1:"33"
PRINT #1:Z+L/2
PRINT #1:"0"
PRINT #1:"3DFACE"
PRINT #1:"8"
PRINT #1:"LAYER1"
PRINT #1:"62"
PRINT #1:"1"
PRINT #1:"10"
PRINT #1:X-L/2
PRINT #1:"20"
PRINT #1:Y-L/2
PRINT #1:"30"
PRINT #1:Z+L/2
PRINT #1:"11"
PRINT #1:X+L/2
PRINT #1:"21"
PRINT #1:Y-L/2
PRINT #1:"31"
PRINT #1:Z+L/2
PRINT #1:"12"
PRINT #1:X+L/2
PRINT #1:"22"
PRINT #1:Y-L/2
PRINT #1:"32"
PRINT #1:Z-L/2
PRINT #1:"13"
PRINT #1:X-L/2
PRINT #1:"23"
PRINT #1:Y-L/2
PRINT #1:"33"
PRINT #1:Z-L/2
PRINT #1:"0"
PRINT #1:"3DFACE"
PRINT #1:"8"
PRINT #1:"LAYER1"
PRINT #1:"62"
PRINT #1:"1"
PRINT #1:"10"
PRINT #1:X-L/2
PRINT #1:"20"
PRINT #1:Y-L/2
PRINT #1:"30"
PRINT #1:Z-L/2
PRINT #1:"11"
PRINT #1:X+L/2
PRINT #1:"21"
PRINT #1:Y-L/2
PRINT #1:"31"
PRINT #1:Z-L/2
PRINT #1:"12"
PRINT #1:X+L/2
PRINT #1:"22"
PRINT #1:Y+L/2
PRINT #1:"32"
PRINT #1:Z-L/2
PRINT #1:"13"
PRINT #1:X-L/2
PRINT #1:"23"
PRINT #1:Y+L/2
PRINT #1:"33"
PRINT #1:Z-L/2
PRINT #1:"0"
PRINT #1:"3DFACE"
PRINT #1:"8"
PRINT #1:"LAYER1"
PRINT #1:"62"
PRINT #1:"1"
PRINT #1:"10"
PRINT #1:X+L/2
PRINT #1:"20"
PRINT #1:Y+L/2
PRINT #1:"30"
PRINT #1:Z-L/2
PRINT #1:"11"
PRINT #1:X+L/2
PRINT #1:"21"
PRINT #1:Y-L/2
PRINT #1:"31"
PRINT #1:Z-L/2
PRINT #1:"12"
PRINT #1:X+L/2
PRINT #1:"22"
PRINT #1:Y-L/2
PRINT #1:"32"
PRINT #1:Z+L/2
PRINT #1:"13"
PRINT #1:X+L/2
PRINT #1:"23"
PRINT #1:Y+L/2
PRINT #1:"33"
PRINT #1:Z+L/2
PRINT #1:"0"
PRINT #1:"3DFACE"
PRINT #1:"8"
PRINT #1:"LAYER1"
PRINT #1:"62"
PRINT #1:"1"
PRINT #1:"10"
PRINT #1:X-L/2
PRINT #1:"20"
PRINT #1:Y-L/2
PRINT #1:"30"
PRINT #1:Z-L/2
PRINT #1:"11"
PRINT #1:X-L/2
PRINT #1:"21"
PRINT #1:Y+L/2
PRINT #1:"31"
PRINT #1:Z-L/2
PRINT #1:"12"
PRINT #1:X-L/2
PRINT #1:"22"
PRINT #1:Y+L/2
PRINT #1:"32"
PRINT #1:Z+L/2
PRINT #1:"13"
PRINT #1:X-L/2
PRINT #1:"23"
PRINT #1:Y-L/2
PRINT #1:"33"
PRINT #1:Z+L/2
END SUB
 

戻る