|
トロコイド型を定義しています。
OPTION BASE 0
OPTION ANGLE DEGREES
RANDOMIZE
LET N=40 !'分割数
DIM X(N,N),Y(N,N),Z(N,N)
DEF HCYC(N,H,T)=((N-1)*COS(T)+H*COS(T*(N-1)))/N
DEF HCYS(N,H,T)=((N-1)*SIN(T)-H*SIN(T*(N-1)))/N
DEF HC3X(N,H,U,V)=HCYS(N,H,U)*HCYC(N,H,V)
DEF HC3Y(N,H,U,V)=HCYS(N,H,U)*HCYS(N,H,V)
DEF HC3Z(N,H,U)=HCYC(N,H,U)
INPUT PROMPT "何角形=":NN
IF NN<3 THEN LET NN=3
LET H=1
FOR J=0 TO N
FOR I=0 TO N
LET ALPHA=J*180/N
LET BETA=I*360/N
LET X(I,J)=HC3X(NN,H,ALPHA,BETA)
LET Y(I,J)=HC3Y(NN,H,ALPHA,BETA)
LET Z(I,J)=HC3Z(NN,H,ALPHA)
NEXT I
NEXT J
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 2.0"
PRINT #1:"trochoid"
PRINT #1:"ASCII"
PRINT #1:"DATASET POLYDATA"
PRINT #1:"POINTS";4*N*N;"float"
FOR J=0 TO N-1
FOR I=0 TO N-1
PRINT #1:X(I+1,J+1);Y(I+1,J+1);Z(I+1,J+1)
PRINT #1:X(I+1,J);Y(I+1,J);Z(I+1,J)
PRINT #1:X(I,J);Y(I,J);Z(I,J)
PRINT #1:X(I,J+1);Y(I,J+1);Z(I,J+1)
NEXT I
NEXT J
PRINT #1:"POLYGONS";N*N;5*N*N
FOR I=0 TO 4*N*N-1 STEP 4
PRINT #1:4;I;I+1;I+2;I+3
NEXT I
PRINT #1:"POINT_DATA";4*N*N
PRINT #1:"SCALARS height float"
PRINT #1:"LOOKUP_TABLE default"
FOR J=0 TO N-1
FOR I=0 TO N-1
PRINT #1:Z(I+1,J+1)
PRINT #1:Z(I+1,J)
PRINT #1:Z(I,J)
PRINT #1:Z(I,J+1)
NEXT I
NEXT J
CLOSE #1
END
|
|