|
クォータニオンをn乗した時の座標を記録しています。
前述と同じように操作してください。
OPTION BASE 0
READ XS,XE,YS,YE,ZS,ZE,N
DATA 5,-5,5,-5,5,-5,30
LET L=2 !'n乗
DIM ZA(3),AA(3),X(N^3),Y(N^3),Z(N^3)
FILE GETSAVENAME F$,"vtkファイル|*.vtk"
IF F$="" THEN STOP
IF POS(UCASE$(F$),".VTK")=0 THEN LET F$=F$&".vtk"
OPEN #1:NAME F$
ERASE #1
PRINT #1:"# vtk DataFile Version 3.0"
PRINT #1:"moire"
PRINT #1:"ASCII"
PRINT #1:"DATASET UNSTRUCTURED_GRID"
PRINT #1:"POINTS";N^3;"float"
FOR ZZ=0 TO N-1
FOR YY=0 TO N-1
FOR XX=0 TO N-1
LET X0=XS+XX*(XE-XS)/N
LET Y0=YS+YY*(YE-YS)/N
LET Z0=ZS+ZZ*(ZE-ZS)/N
LET ZA(0)=1
LET ZA(1)=0
LET ZA(2)=0
LET ZA(3)=0
LET AA(0)=X0
LET AA(1)=Y0
LET AA(2)=Z0
LET AA(3)=0
FOR I=1 TO L !'L乗する
CALL MUL(ZA,ZA,AA) !'ZA=ZA*AA モアレ模様
NEXT I
PRINT #1:ZA(0);ZA(1);ZA(2)
LET K=K+1
LET X(K)=ZA(0)
LET Y(K)=ZA(1)
LET Z(K)=ZA(2)
NEXT XX
NEXT YY
NEXT ZZ
PRINT #1:"CELL_TYPES";N^3
FOR I=1 TO N^3
PRINT #1:1
NEXT I
PRINT #1:"POINT_DATA";N^3
PRINT #1:"SCALARS distance float"
PRINT #1:"LOOKUP_TABLE default"
FOR I=1 TO K
PRINT #1:SQR(X(I)^2+Y(I)^2+Z(I)^2)
NEXT I
CLOSE #1
END
EXTERNAL SUB MUL(S(),A(),B())
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
|
|