|
角錐ですが、底面が星型をしています。
INPUT PROMPT "長さ L1=":L1
!'INPUT PROMPT "長さ L2(L1>L2)=":L2
INPUT PROMPT "高さ=":H
LET X1=COS(PI/2) !'半径1とする 頂点1番
LET Y1=SIN(PI/2)
LET X2=COS(PI/2+2*PI/5) !'頂点2番
LET Y2=SIN(PI/2+2*PI/5)
LET X3=COS(PI/2+2*PI/5*2) !'頂点3番
LET Y3=SIN(PI/2+2*PI/5*2)
LET XN=COS(PI/2+2*PI/5*4) !'頂点N番
LET YN=SIN(PI/2+2*PI/5*4)
CALL CROSS(X1,Y1,X3,Y3,X2,Y2,XN,YN,XX,YY) !'頂点1と頂点3を結ぶ直線,頂点2と頂点N番とを結ぶ直線との交点
LET RR=SQR(XX^2+YY^2) !'原点からの距離(比率)
LET L2=L1*RR
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:"star"
PRINT #1:"ASCII"
PRINT #1:"DATASET POLYDATA"
PRINT #1:"POINTS";11;"float"
FOR TH=0 TO 359 STEP 72
LET X=L1*COS(TH*PI/180)
LET Z=L1*SIN(TH*PI/180)
LET Y=0
PRINT #1:X;Y;Z
NEXT TH
FOR TH=0 TO 359 STEP 72
LET X=L2*COS((TH+36)*PI/180)
LET Z=L2*SIN((TH+36)*PI/180)
LET Y=0
PRINT #1:X;Y;Z
NEXT TH
PRINT #1:0,H,0
PRINT #1:"POLYGONS";18;72
PRINT #1:"3 0 9 5"
PRINT #1:"3 1 5 6"
PRINT #1:"3 2 6 7"
PRINT #1:"3 3 7 8"
PRINT #1:"3 4 8 9"
PRINT #1:"3 5 6 7"
PRINT #1:"3 5 7 8"
PRINT #1:"3 5 8 9"
PRINT #1:"3 10 9 0"
PRINT #1:"3 10 0 5"
PRINT #1:"3 10 5 1"
PRINT #1:"3 10 1 6"
PRINT #1:"3 10 6 2"
PRINT #1:"3 10 2 7"
PRINT #1:"3 10 7 3"
PRINT #1:"3 10 3 8"
PRINT #1:"3 10 8 4"
PRINT #1:"3 10 4 9"
CLOSE #1
END
EXTERNAL SUB CROSS(X1,Y1,X2,Y2,X3,Y3,X4,Y4,X,Y)
!'点(X1,Y1)と点(X2,Y2)を結ぶ直線
!'点(X3,Y3)と点(X4,Y4)を結ぶ直線
!'との交点(X,Y)を求める
LET A=(Y2-Y1)/(X2-X1)
LET B=(Y4-Y3)/(X4-X3)
LET X=(Y3-Y1+A*X1-B*X3)/(A-B)
LET Y=A*X+Y1
END SUB
|
|