|
!'ボクセル表現(VOXEL)
OPTION BASE 0
DIM CC(3),ZZ(3)
READ XS,XE,YS,YE,ZS,ZE,MAXITER,N
DATA -2.2,0.5,-1.35,1.35,-1.35,1.35,50,50 !'(要)調整
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=YS TO YE STEP (YE-YS)/N
FOR X=XS TO XE STEP (XE-XS)/N
FOR Z=ZS TO ZE STEP (ZE-ZS)/N
LET CC(0)=X !'初期値
LET CC(1)=Y
LET CC(2)=Z
LET CC(3)=0
MAT ZZ=ZER
FOR I=1 TO MAXITER
CALL MUL(ZZ,ZZ,ZZ) !'Z=Z^2+C(クォータニオン演算)
CALL ADD(ZZ,ZZ,CC)
IF ZZ(0)^2+ZZ(1)^2+ZZ(2)^2+ZZ(3)^2>4 THEN EXIT FOR
NEXT I
IF I>MAXITER THEN CALL RECT(#1,X,Y,Z,(XE-XS)/N,(YE-YS)/N,(ZE-ZS)/N)
NEXT Z
NEXT X
NEXT Y
PRINT #1:"0"
PRINT #1:"ENDSEC"
PRINT #1:"0"
PRINT #1:"EOF"
CLOSE #1
END
EXTERNAL SUB MUL(S(),A(),B()) !'クォータニオン(4元数)掛算
OPTION BASE 0
DIM SS(3)
LET SS(0)=A(0)*B(0)-A(1)*B(1)-A(2)*B(2)-A(3)*B(3)
LET SS(1)=A(0)*B(1)+A(1)*B(0)+A(2)*B(3)-A(3)*B(2)
LET SS(2)=A(0)*B(2)-A(1)*B(3)+A(2)*B(0)+A(3)*B(1)
LET SS(3)=A(0)*B(3)+A(1)*B(2)-A(2)*B(1)+A(3)*B(0)
MAT S=SS
END SUB
EXTERNAL SUB ADD(S(),A(),B())
OPTION BASE 0
DIM SS(3)
MAT SS=A+B
MAT S=SS
END SUB
以下省略
EXTERNAL SUB RECT(#1,XX,YY,ZZ,XL,YL,ZL)
END SUB
|
|