|
ここでは超楕円体を定義しています。
OPTION ANGLE DEGREES
RANDOMIZE
LET N=40 !'分割数
LET NN=RND*8
LET MM=RND*8
DIM XX(N*(N-1)+2),YY(N*(N-1)+2),ZZ(N*(N-1)+2)
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:"hyper ellipse"
PRINT #1:"ASCII"
PRINT #1:"DATASET POLYDATA"
PRINT #1:"POINTS";N*(N-1)+2;"float"
LET ALPHA=0
LET BETA=0
LET X=-SGN(SIN(ALPHA))*ABS(SIN(ALPHA))^NN*SGN(COS(BETA))*ABS(COS(BETA))^MM
LET Y=SGN(COS(ALPHA))*ABS(COS(ALPHA))^NN
LET Z=SGN(SIN(ALPHA))*ABS(SIN(ALPHA))^NN*SGN(SIN(BETA))*ABS(SIN(BETA))^MM
PRINT #1:X;Y;Z
LET K=K+1
LET XX(K)=X
LET YY(K)=Y
LET ZZ(K)=Z
FOR ALPHA=180/N TO 179 STEP 180/N
FOR BETA=0 TO 359 STEP 360/N
LET X=-SGN(SIN(ALPHA))*ABS(SIN(ALPHA))^NN*SGN(COS(BETA))*ABS(COS(BETA))^MM
LET Y=SGN(COS(ALPHA))*ABS(COS(ALPHA))^NN
LET Z=SGN(SIN(ALPHA))*ABS(SIN(ALPHA))^NN*SGN(SIN(BETA))*ABS(SIN(BETA))^MM
PRINT #1:X;Y;Z
LET K=K+1
LET XX(K)=X
LET YY(K)=Y
LET ZZ(K)=Z
NEXT BETA
NEXT ALPHA
LET ALPHA=180
LET BETA=0
LET X=-SGN(SIN(ALPHA))*ABS(SIN(ALPHA))^NN*SGN(COS(BETA))*ABS(COS(BETA))^MM
LET Y=SGN(COS(ALPHA))*ABS(COS(ALPHA))^NN
LET Z=SGN(SIN(ALPHA))*ABS(SIN(ALPHA))^NN*SGN(SIN(BETA))*ABS(SIN(BETA))^MM
PRINT #1:X;Y;Z
LET K=K+1
LET XX(K)=X
LET YY(K)=Y
LET ZZ(K)=Z
PRINT #1:"POLYGONS";N*N;8*N+N*(N-2)*5
FOR I=1 TO N
IF I=N THEN
PRINT #1:3;1;0;N
ELSE
PRINT #1:3;0;I;I+1
END IF
NEXT I
FOR I=1 TO N*(N-2)
IF MOD(I,N)=0 THEN
PRINT #1:4;I;I+N;I+1;I-N+1
ELSE
PRINT #1:4;I;I+N;I+N+1;I+1
END IF
NEXT I
FOR I=N*(N-2)+1 TO N*(N-1)
IF I=N*(N-1) THEN
PRINT #1:3;N*(N-1);N*(N-1)+1;N*(N-2)+1
ELSE
PRINT #1:3;I;N*(N-1)+1;I+1
END IF
NEXT I
PRINT #1:"POINT_DATA";N*(N-1)+2
PRINT #1:"SCALARS height float"
PRINT #1:"LOOKUP_TABLE default"
FOR I=1 TO K
PRINT #1:ZZ(I)
NEXT I
CLOSE #1
END
|
|