|
立方体を3点透視で表示します
OPTION ARITHMETIC NATIVE
OPTION ANGLE DEGREES
SET POINT STYLE 1
LET LMIN=1E+10
LET LMAX=-1E+10
LET L=100
LET F=100 !'視点から投影面までの距離
LOCATE VALUE NOWAIT(1),RANGE -90 TO 90,AT 0:BETA
LOCATE VALUE NOWAIT(2),RANGE -180 TO 0,AT -90:GAMMA
LOCATE VALUE NOWAIT(3),RANGE 0 TO 1000,AT 100:D1
LOCATE VALUE NOWAIT(4),RANGE -500 TO 1000,AT 0:D2
LOCATE VALUE NOWAIT(5),RANGE -500 TO 1000,AT 0:D3
DO
LOCATE VALUE NOWAIT(1):BETA
LOCATE VALUE NOWAIT(2):GAMMA
LOCATE VALUE NOWAIT(3):D1
LOCATE VALUE NOWAIT(4):D2
LOCATE VALUE NOWAIT(5):D3
SET DRAW MODE HIDDEN
CLEAR
CALL CUBE(0,0,0,L)
IF FL=0 THEN
SET WINDOW LMIN*2,LMAX*2,LMIN*2,LMAX*2
END IF
LET FL=1
SET DRAW MODE EXPLICIT
LOOP
SUB PLOT(X,Y,Z)
LET SY=SIN(BETA)
LET CY=COS(BETA)
LET SZ=SIN(GAMMA)
LET CZ=COS(GAMMA)
LET X1=CY*SZ*(X-D1)-CY*CZ*(Y-D2)-SY*(Z-D3)
LET Y1=CZ*(X-D1)+SZ*(Y-D2)
LET Z1=SY*SZ*(X-D1)-SY*CZ*(Y-D2)-CY*(Z-D3)
LET XX=-F*Y1/X1
LET YY=-F*Z1/X1
IF FL=0 THEN
LET LMIN=MIN(LMIN,XX)
LET LMAX=MAX(LMAX,XX)
LET LMIN=MIN(LMIN,YY)
LET LMAX=MAX(LMAX,YY)
ELSE
PLOT LINES:XX,YY;
END IF
END SUB
SUB PLOTLINE(X1,Y1,Z1,X2,Y2,Z2)
PLOT LINES
CALL PLOT(X1,Y1,Z1)
CALL PLOT(X2,Y2,Z2)
PLOT LINES
END SUB
SUB CUBE(X,Y,Z,L)
CALL PLOT(X-L/2,Y+L/2,Z-L/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