球面反射変換

 投稿者:しばっち  投稿日:2015年 5月30日(土)22時10分31秒
  !'球面反射変換
FILE GETNAME F$,"BMP,JPG,GIF,PNGファイル|*.BMP;*.JPG;*.GIF;*.PNG"
CALL PICTURELOAD(F$,XSIZE,YSIZE)
DIM M(0 TO XSIZE-1,0 TO YSIZE-1)
ASK PIXEL ARRAY (0,0) M
!'球面反射変換
!' Z=(2*R*R)/(X*X+Y*Y+R*R)
!' X'=X*Z
!' Y'=Y*Z
!' 逆変換
!' X=X'/Z
!' Y=Y'/Z
LET XO=XSIZE/2
LET YO=YSIZE/2
!'INPUT  PROMPT "半径=":R
LET R=MIN(XO,YO)
CLEAR
FOR Y=0 TO YSIZE-1
   FOR X=0 TO XSIZE-1
      IF SQR((X-XO)^2+(Y-YO)^2)<R THEN
         LET Z=(2*R*R)/((X-XO)*(X-XO)+(Y-YO)*(Y-YO)+R*R)
         LET XX=X/Z
         LET YY=Y/Z
      ELSE
         LET XX=X
         LET YY=Y
      END IF
      LET C=M(INT(XX),INT(YY))
      CALL RGB(C,RR,GG,BB)
      CALL PSET(X,Y,RR,GG,BB)
   NEXT X
NEXT Y
END

EXTERNAL SUB RGB(X,R,G,B)
LET B=MOD(INT(X/65536),256)
LET G=MOD(INT(X/256),256)
LET R=MOD(X,256)
END SUB

EXTERNAL SUB GINIT(XSIZE,YSIZE)
SET BITMAP SIZE XSIZE,YSIZE
SET COLOR MODE "NATIVE"
CLEAR
SET POINT STYLE 1
SET WINDOW 0,XSIZE-1,YSIZE-1,0
END SUB

EXTERNAL SUB PSET(X,Y,R,G,B)
SET COLOR COLORINDEX(R/255,G/255,B/255)
PLOT POINTS:X,Y
END SUB

EXTERNAL SUB PICTURELOAD(N$,XSIZE,YSIZE)
SET COLOR MODE "NATIVE"
CLEAR
SET POINT STYLE 1
IF N$="" THEN STOP
GLOAD N$
LET XSIZE=PIXELX(1)+1
LET YSIZE=PIXELY(1)+1
SET BITMAP SIZE XSIZE,YSIZE
SET WINDOW 0,XSIZE-1,YSIZE-1,0
END SUB

 

戻る