Amnesie Guru Joined: 30/06/2020 Location: GermanyPosts: 746
Posted: 06:34am 03 Aug 2025
Martin H. said I've found a little listing in Facebook and converted it to run in MMBasic Here the PicomiteVGA Versionmode 2 ' 320x240 Const SCREEN_HEIGHT = 480 Const Q = 3 Dim XP(Q), YP(Q), ZP(Q) As Integer Dim MX(26,26), MY(26,26) As Integer cls ' Define charge points XP(1) = 11 : YP(1) = 6 : ZP(1) = 175 XP(2) = 17 : YP(2) = 18 : ZP(2) = -150 XP(3) = 7 : YP(3) = 19 : ZP(3) = 40 ' Projection constants Dim XS , YS As Integer XS = 25: YS = 200 ' Fill matrix with transformed coordinates For X = 0 To 25 For Y = 0 To 25 UPJE = 0 For W = 1 To Q D = Sqr((X - XP(W))^2 + (Y - YP(W))^2) inc UPJE, ZP(W) * Exp(-D / 2) Next ' Fix grid orientation (X then Y) MX(X,Y) = XS + 11*X + 11*Y ' Flip Y-axis (to match PC-BASIC lower-left origin) MY(X,Y) = SCREEN_HEIGHT - (UPJE + YS - X*4 + Y*4) ' Optional: show control points Pixel MX(X,Y)/2, MY(X,Y)/2, rgb(0,255,255) Next Next ' Draw the surface E = 0 For Y = 25 To 1 Step -1 For X = 0 To 24 X1 = MX(X,Y)/2: Y1 = MY(X,Y)/2 X2 = MX(X+1,Y)/2: Y2 = MY(X+1,Y)/2 X3 = MX(X+1,Y-1)/2: Y3 = MY(X+1,Y-1)/2 X4 = MX(X,Y-1)/2: Y4 = MY(X,Y-1)/2 ' Fill with alternating pattern If (E Mod 2 = 0) Then K = RGB(0,0,255) else K = RGB(0,128,255) endif TRIANGLE X1, Y1, X2, Y2,X3, Y3 ,k,k TRIANGLE X1, Y1, X4, Y4,X3, Y3 ,k,k Line X1,Y1 ,X2,Y2,, K Line X2,Y2 ,X3,Y3,, K Line X3,Y3,X4,Y4,, K Line X4,Y4,X1,Y1,, K XPc = (X1 + X3) \ 2 YPc = (Y1 + Y3) \ 2 ' Highlight border K = RGB(255,255,255) Line X1,Y1,X2,Y2,, K Line X2,Y2 ,X3,Y3,, K Line X3,Y3,X4,Y4,, K Line X4,Y4,X1,Y1,, K inc E Next Next
Since the program was designed for 640x360, I divided all screen coordinates by 2.Not elegant but it works Cheers Martin Martin, this is funny, I saw the same exact post in this Facebook-Group, too and also wondered if it can be translated to MMBASIC And now you're posting this! Hah! Greetings Daniel