回転体

 投稿者:しばっち  投稿日:2011年 8月14日(日)23時11分17秒
  OPTION BASE 0
DIM X(100,100),Y(100,100),Z(100,100)
INPUT  PROMPT "MODE(0 - 47)=":MODE
FOR I=0 TO MODE
   READ N,M,S0,E0,S1,E1,FF$
NEXT I
DATA 20,20,0,360,0,360,"トーラス" !'0
DATA 20,20,0,360,0,360,"パイン" !'1
DATA 20,20,0,360,0,360,"円柱" !'2
DATA 20,20,0,360,-180,180,"一葉双曲面" !'3
DATA 20,20,0,360,0,360,"カクテルグラス" !'4
DATA 20,20,0,360,-57,160,"ワイングラス" !'5
DATA 20,20,0,360,0,360,"アステロイド回転" !'6
DATA 20,20,0,360,0,360,"とんがり帽子" !'7
DATA 20,20,0,360,0,360,"トーラス2" !'8
DATA 20,20,0,360,0,360,"トーラス3" !'9
DATA 20,20,0,360,0,360,"トーラス4" !'10
DATA 20,100,0,360,0,1800,"トーラス5" !'11
DATA 20,100,0,360,0,1800,"トーラス6" !'12
DATA 20,20,0,360,-54,90,"花瓶" !'13
DATA 20,20,0,360,116,486,"壷" !'14
DATA 20,20,0,360,0,360,"ワイングラス2" !'15
DATA 20,20,0,360,-51,68,"タンブラーグラス" !'16
DATA 20,20,0,360,0,360,"カクテルグラス2" !'17
DATA 20,100,0,360,0,1800,"螺旋" !'18
DATA 20,60,0,360,0,1080,"トーラス7" !'19
DATA 20,20,0,180,0,360,"球" !'20
DATA 20,20,90,360,0,360,"トーラス8" !'21
DATA 20,20,0,360,0,900,"トーラス9" !'22
DATA 20,20,0,360,0,360,"トーラス10" !'23
DATA 20,4,0,360,-17,17,"トーラス11" !'24
DATA 20,20,0,360,0,360,"超楕円面" !'25
DATA 20,20,0,360,0,360,"超1葉双曲面" !'26
DATA 20,20,0,180,0,360,"超2葉双曲面" !'27
DATA 20,20,0,360,0,360,"超トーラス面" !'28
DATA 20,20,-180,180,-180,180,"星芒形球面" !'29
DATA 20,20,-1,1,0,360,"カテノイド" !'30
DATA 20,20,-.8,.8,-2,2,"つばめの尾" !'31
DATA 20,20,0,360,0,360,"ボヘミアンドーム" !'32
DATA 20,20,-1,1,-1,1,"エヌバー曲面" !'33
DATA 20,20,0,360,0,360,"巻き貝" !'34
DATA 20,20,0,360,0,360,"ロマン曲面" !'35
DATA 20,20,-180,180,0,180,"ボーイ曲面" !'36
DATA 20,20,0,360,0,360,"クエン" !'37
DATA 20,20,0,4320,0,360,"トーラス結び目" !'38
DATA 20,20,-360,360,-2,2,"カタラン" !'39
DATA 20,20,0,720,.05,2,"ディニー" !'40
DATA 20,20,0,360,-2,2,"ヘリコイド" !'41
DATA 20,20,-1,1,0,360,"ヘンネベルク" !'42
DATA 20,20,0,360,0,360,"クラインの壷" !'43
DATA 20,20,0,360,0,360,"COS回転体" !'44
DATA 20,20,0,360,0,360,"COS回転体2" !'45
DATA 20,20,0,360,0,360,"立方体" !'46
DATA 20,20,0,360,0,360,"レムニスケート" !'47
FOR J=0 TO M
   LET BETA=S1+J*(E1-S1)/M
   FOR I=0 TO N
      LET ALPHA=S0+I*(E0-S0)/N
      CALL FUNC(MODE,ALPHA,BETA,X(J,I),Y(J,I),Z(J,I))
   NEXT I
NEXT  J
FILE GETSAVENAME F$,"dxfファイル|*.dxf"
IF F$="" THEN STOP
IF RIGHT$(F$,1)="!" THEN LET F$=F$(1:LEN(F$)-1) & FF$
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 I=0 TO M-1
   FOR J=0 TO N-1
      PRINT #1:"0"
      PRINT #1:"3DFACE"
      PRINT #1:"8"
      PRINT #1:"LAYER1"
      PRINT #1:"62"
      PRINT #1:"1"
      PRINT #1:"10"
      PRINT #1:X(I,J)
      PRINT #1:"20"
      PRINT #1:Y(I,J)
      PRINT #1:"30"
      PRINT #1:Z(I,J)
      PRINT #1:"11"
      PRINT #1:X(I,J+1)
      PRINT #1:"21"
      PRINT #1:Y(I,J+1)
      PRINT #1:"31"
      PRINT #1:Z(I,J+1)
      PRINT #1:"12"
      PRINT #1:X(I+1,J+1)
      PRINT #1:"22"
      PRINT #1:Y(I+1,J+1)
      PRINT #1:"32"
      PRINT #1:Z(I+1,J+1)
      PRINT #1:"13"
      PRINT #1:X(I+1,J)
      PRINT #1:"23"
      PRINT #1:Y(I+1,J)
      PRINT #1:"33"
      PRINT #1:Z(I+1,J)
   NEXT  J
NEXT  I
PRINT #1:"0"
PRINT #1:"ENDSEC"
PRINT #1:"0"
PRINT #1:"EOF"
CLOSE #1
END

EXTERNAL  SUB FUNC(MODE,TT,SS,X,Y,Z)
LET  S=SS*PI/180
LET  T=TT*PI/180
SELECT CASE MODE
CASE 0
   LET  X=(2+0.5*COS(T))*COS(S)
   LET  Y=0.5*SIN(T)
   LET  Z=(2+0.5*COS(T))*SIN(S)
CASE 1
   LET  X=INT(2+0.5*COS(T))*COS(S)
   LET  Y=0.5*SIN(T)
   LET  Z=INT(2+0.5*COS(T))*SIN(S)
CASE 2
   LET  X=COS(T)
   LET  Y=S
   LET  Z=SIN(T)
CASE 3
   LET  X=COSH(S)*COS(T)
   LET  Y=SINH(S)
   LET  Z=COSH(S)*SIN(T)
CASE 4
   LET  X=(INT(S+1)+INT(S-1.5)-2.35)*COS(T)
   LET  Y=S
   LET  Z=(INT(S+1)+INT(S-1.5)-2.35)*SIN(T)
CASE 5
   IF S=0 THEN
      LET  X=0
      LET  Z=0
   ELSE
      LET  X=MAX(S^2*SIN(1/S^2),0.1)*COS(T)
      LET  Z=MAX(S^2*SIN(1/S^2),0.1)*SIN(T)
   END IF
   LET  Y=S
CASE 6
   LET  X=4*COS(S)^3*COS(T)
   LET  Z=4*COS(S)^3*SIN(T)
   LET  Y=4*SIN(S)^3
CASE 7
   LET  X=S*COS(T)
   LET  Z=S*SIN(T)
   LET  Y=6*EXP(-S^(2/3))
CASE 8
   LET  X=(2+0.5*COS(T))*COS(S)
   LET  Y=0.5*SIN(T)+0.2*SIN(5*S)
   LET  Z=(2+0.5*COS(T))*SIN(S)
CASE 9
   LET  X=(2+0.3*COS(T)+COS(10*S))*COS(S)
   LET  Y=1.5*SIN(T)+1.2*SIN(10*S)
   LET  Z=(2+0.3*COS(T)+COS(10*S))*SIN(S)
CASE 10
   LET  X=(2+0.5*COS(T))*(1+0.4*COS(5*S))*COS(S)
   LET  Z=(2+0.5*COS(T))*(1+0.4*COS(5*S))*SIN(S)
   LET  Y=0.5*SIN(T)
CASE 11
   LET  X=(3-S/10+0.5*COS(T))*COS(S)
   LET  Z=(3-S/10+0.5*COS(T))*SIN(S)
   LET  Y=0.5*SIN(T)+S/6
CASE 12
   LET  X=(3-S/10+0.5*COS(T))*(1-S/10/PI)*COS(S)
   LET  Z=(3-S/10+0.5*COS(T))*(1-S/10/PI)*SIN(S)
   LET  Y=0.5*(1-S/10/PI)*SIN(T)+S/6
CASE 13
   LET  X=(3*COS(S)-3.5)*COS(T)
   LET  Y=2*SIN(S)-1
   LET  Z=(3*COS(S)-3.5)*SIN(T)
CASE 14
   LET  X=(2-INT(COS(T)))*COS(S)
   LET  Y=T
   LET  Z=(2-INT(COS(T)))*SIN(S)
CASE 15
   LET  Y=S
   LET  X=(ABS(1.1*SQR(S)-1)+ABS(1.1*SQR(S)-2)-.8)*COS(T)
   LET  Z=(ABS(1.1*SQR(S)-1)+ABS(1.1*SQR(S)-2)-.8)*SIN(T)
CASE 16
   LET  X=(0.5*SIN(PI*S)+0.5*S^2+.5)*COS(T)
   LET  Z=(0.5*SIN(PI*S)+0.5*S^2+.5)*SIN(T)
   LET  Y=S
CASE 17
   LET  X=(ABS(S^.7-1)+ABS(S^.7-4^.7)-1.5)*COS(T)
   LET  Z=(ABS(S^.7-1)+ABS(S^.7-4^.7)-1.5)*SIN(T)
   LET  Y=S
CASE 18
   LET  X=(2+0.5*COS(T))*COS(S)
   LET  Y=0.5*SIN(T)+S/5
   LET  Z=(2+0.5*COS(T))*SIN(S)
CASE 19
   LET  X=(2+2.2^(1-S/6/PI)*COS(T))*(1-S/6/PI)*COS(S)
   LET  Z=-(2+2.2^(1-S/6/PI)*COS(T))*(1-S/6/PI)*SIN(S)
   LET  Y=2.2^(1-S/6/PI)*(1-S/6/PI)*SIN(T)+10*S/6/PI
CASE 20
   LET  X=-S*SIN(T)*COS(S)
   LET  Z=S*SIN(T)*SIN(S)
   LET  Y=S*COS(T)
CASE 21
   LET  X=(3+5*COS(S))*COS(T)
   LET  Z=(3+5*COS(S))*SIN(T)
   LET  Y=5*SIN(S)
CASE 22
   LET  X=(2+EXP(-.1*T)*COS(S))*COS(T)
   LET  Z=(2+EXP(-.1*T)*COS(S))*SIN(T)
   LET  Y=EXP(-.1*T)*SIN(S)
CASE 23
   LET  X=(9+4*COS(S))*COS(7*T)
   LET  Z=(9+4*COS(S))*SIN(7*T)
   LET  Y=4*SIN(S)
CASE 24
   LET  X=(9+4*COS(S+11*T))*COS(T)
   LET  Z=(9+4*COS(S+11*T))*SIN(T)
   LET  Y=4*SIN(S+11*T)
CASE 25
   LET  X=.5*SGN(COS(S))*ABS(COS(S))^1.5*SGN(COS(T))*ABS(COS(T))^.5
   LET  Z=.7*SGN(SIN(S))*ABS(SIN(S))^1.5*SGN(COS(T))*ABS(COS(T))^.5
   LET  Y=SGN(SIN(T))*ABS(SIN(T))^.5
CASE 26
   LET  X=.5*SGN(COS(S))*ABS(COS(S))^1.7*SGN(COSH(T))*ABS(COSH(T))^1.2
   LET  Z=.7*SGN(SIN(S))*ABS(SIN(S))^1.7*SGN(COSH(T))*ABS(COSH(T))^1.2
   LET  Y=SGN(SINH(T))*ABS(SINH(T))^1.2
CASE 27
   LET  X=.5*SGN(COS(S))*ABS(COS(S))^2.7*SGN(SINH(T))*ABS(SINH(T))^2.3
   LET  Z=.7*SGN(SIN(S))*ABS(SIN(S))^2.7*SGN(SINH(T))*ABS(SINH(T))^2.3
   LET  Y=SGN(COSH(T))*ABS(COSH(T))^2.3
CASE 28
   LET  X=.5*SGN(COS(S))*ABS(COS(S))^2.5*(2+SGN(COS(T))*ABS(COS(T))^.4)
   LET  Z=.7*SGN(SIN(S))*ABS(SIN(S))^2.5*(2+SGN(COS(T))*ABS(COS(T))^.4)
   LET  Y=SGN(SIN(T))*ABS(SIN(T))^.4
CASE 29
   LET  X=(1.5*COS(S)*COS(T))^3
   LET  Y=(1.5*SIN(T))^3
   LET  Z=(1.5*SIN(S)*COS(T))^3
CASE 30
   LET  X=COSH(TT)*COS(S)
   LET  Y=TT
   LET  Z=COSH(TT)*SIN(S)
 

Re: 回転体

 投稿者:しばっち  投稿日:2011年 8月14日(日)23時13分0秒
  > No.1621[元記事へ]

続き

CASE 31
   LET  X=SS*TT^2+3*TT^4
   LET  Y=TT
   LET  Z=-2*SS*TT-4*TT^3
CASE 32
   LET  X=0.5*COS(S)
   LET  Y=SIN(T)
   LET  Z=1.5*COS(T)+0.5*SIN(S)
CASE 33
   LET  X=3*SS+3*SS*TT^2-SS^3
   LET  Y=3*SS^2-3*TT^2
   LET  Z=3*TT+3*SS^2*TT-TT^3
CASE 34
   LET  X=.1*(1-T/2/PI)*COS(3*T)*(1+COS(S))+0.1*COS(3*T)
   LET  Y=0.5*T/2/PI+0.1*(1-T/2/PI)*SIN(S)
   LET  Z=0.1*(1-T/2/PI)*SIN(3*T)*(1+COS(S))+0.1*SIN(3*T)
CASE 35
   LET  X=SQR(2)*COS(2*S)*COS(T)^2+COS(S)*SIN(2*T)
   LET  Y=3/2*COS(T)^2
   LET  Z=SQR(2)*SIN(2*S)*COS(T)^2-SIN(S)*SIN(2*T)
CASE 36
   LET  X=(SQR(2)*COS(2*S)*COS(T)^2+COS(S)*SIN(2*T))/(2-SQR(2)*SIN(3*S)*SIN(2*T))
   LET  Y=3*COS(T)^2/(2-SQR(2)*SIN(3*S)*SIN(2*T))
   LET  Z=(SQR(2)*SIN(2*S)*COS(T)^2-SIN(S)*SIN(2*T))/(2-SQR(2)*SIN(3*S)*SIN(2*T))
CASE 37
   LET  X=2*(COS(S)+S*SIN(S))*SIN(T)/(1+S^2*SIN(T)^2)
   LET  Y=2*COS(T)/(1+S^2*SIN(T)^2)
   LET  Z=2*(SIN(S)-S*COS(S))*SIN(T)/(1+S^2*SIN(T)^2)
CASE 38
   LET  X=(3+COS(S/2))*COS(S/3)+COS(S/3)*COS(T-PI)
   LET  Y=SIN(S/2)+SIN(T-PI)
   LET  Z=(3+COS(S/2))*SIN(S/3)+SIN(S/3)*COS(T-PI)
CASE 39
   LET  X=S-SIN(S)*COSH(TT)
   LET  Y=4*SIN(S/2)*SINH(TT)
   LET  Z=1-COS(S)*COSH(TT)
CASE 40
   LET  X=COS(S)*SIN(TT)
   LET  Y=COS(TT)+LOG(TAN(TT/2))+0.2*S
   LET  Z=SIN(S)*SIN(TT)
CASE 41
   LET  X=COS(0.5)*SINH(TT)*SIN(S)+SIN(0.5)*COSH(TT)*COS(S)
   LET  Y=S*COS(0.5)+TT*SIN(0.5)
   LET  Z=-COS(0.5)+SINH(TT)*COS(S)+SIN(0.5)*COSH(TT)*SIN(S)
CASE 42
   LET  X=2*SINH(SS)*COS(T)-2/3*SINH(3*SS)*COS(3*T)
   LET  Y=2*COSH(2*SS)*COS(2*T)
   LET  Z=2*SINH(SS)*SIN(T)+2/3*SINH(3*SS)*SIN(3*T)
CASE 43
   IF S<PI THEN
      LET  X=6*COS(S)*(1+SIN(S))+4*(1-COS(S))*COS(T)
   ELSE
      LET  X=6*COS(S)*(1+SIN(S))+4*(1-COS(S)/2)*COS(T+PI)
   END IF
   IF S<PI THEN
      LET  Y=16*SIN(S)+4*(1-COS(S)/2)*SIN(S)*COS(T)
   ELSE
      LET  Y=16*SIN(S)
   END IF
   LET  Z=4*(1-COS(S)/2)*SIN(T)
CASE 44
   LET  X=S*COS(T)
   LET  Y=COS(S)
   LET  Z=S*SIN(T)
CASE 45
   LET  X=(3+COS(4*S))*COS(T)
   LET  Z=(3+SIN(4*S))*SIN(T)
   LET  Y=S*3
CASE 46
   LET  X=SGN(COS(S))*ABS(COS(S))^.1*SGN(COS(T))*ABS(COS(T))^.1
   LET  Z=SGN(SIN(S))*ABS(SIN(S))^.1*SGN(COS(T))*ABS(COS(T))^.1
   LET  Y=SGN(SIN(T))*ABS(SIN(T))^.1
CASE 47
   LET  X=SIN(S)*COS(S)/(1+SIN(S)^2)*COS(T)
   LET  Z=SIN(S)*COS(S)/(1+SIN(S)^2)*SIN(T)
   LET  Y=COS(S)/(1+SIN(S)^2)
END SELECT
END SUB

画像作成に「Easy View for 3D  Ver.1.69」を使用した

下記画像は16番「タンブラーグラス」
 

戻る