From: Svjatoslav Agejenko Date: Tue, 29 Jul 2025 01:00:47 +0000 (+0300) Subject: Improve application listing on the web X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=commitdiff_plain;h=a0ee1f65d465a4da8ce11a0a32162c70a2d173c1;p=qbasicapps.git Improve application listing on the web --- diff --git a/2D GFX/Fractals/index.html b/2D GFX/Fractals/index.html index 94b7f32..3b83782 100644 --- a/2D GFX/Fractals/index.html +++ b/2D GFX/Fractals/index.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Fractals @@ -210,11 +210,11 @@

Table of Contents

@@ -236,8 +236,8 @@ -
-

1. Fractal circles

+
+

1. Fractal circles

This QBasic program generates a visually captivating spiral fractal @@ -247,7 +247,7 @@ geometry, recursive programming, and graphical design.

-
+

fractal%20circles.png

@@ -266,8 +266,8 @@ indefinitely.
-
-

2. Fractal circles animated

+
+

2. Fractal circles animated

This QBasic program creates an animated fractal composed of circles, @@ -287,29 +287,29 @@ system to control the animation's progression.

-
-

3. Fractal of squares

+
+

3. Fractal of squares

This QBasic program generates and displays a fractal pattern composed of squares.

-
+

fractal%20squares,%201.png

-
+

fractal%20squares,%202.png

-
-

4. Fractal of squares animated

+
+

4. Fractal of squares animated

This QBasic program generates an animated fractal pattern composed of @@ -331,8 +331,8 @@ resulting in a dynamic and ever-changing geometric pattern.

-
-

5. Fractal of trees

+
+

5. Fractal of trees

QBasic program that generates a visually appealing fractal tree @@ -355,7 +355,7 @@ resembles a tree, with branches that grow and change over time.

-

Created: 2025-07-29 ti 00:24

+

Created: 2025-07-29 ti 03:07

Validate

diff --git a/2D GFX/Spirals/index.html b/2D GFX/Spirals/index.html index 1cc5921..10943cb 100644 --- a/2D GFX/Spirals/index.html +++ b/2D GFX/Spirals/index.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Spiral series @@ -210,12 +210,12 @@

Table of Contents

@@ -236,11 +236,11 @@ } -
-

1. Spiral with increasing density

+
+

1. Spiral with increasing density

-
+

spiral.png

@@ -320,11 +320,11 @@ userInput$ = INPUT$(1)
-
-

2. Spiral with varying height

+
+

2. Spiral with varying height

-
+

spiral, 2.png

@@ -391,11 +391,11 @@ a$ = INPUT$(1)
-
-

3. Shaded spiral

+
+

3. Shaded spiral

-
+

spiral, 3.png

@@ -497,8 +497,8 @@ a$ = INPUT$(1)
-
-

4. Sphere forming spiral

+
+

4. Sphere forming spiral

Similar to previous spiral, Line segments are connected between the @@ -507,7 +507,7 @@ multiple linked spherical shapes. Initially point cloud in shown:

-
+

spiral, 4, 1.png

@@ -517,7 +517,7 @@ In the next step, points are connected using lines:

-
+

spiral, 4, 2.png

@@ -622,11 +622,11 @@ a$ = INPUT$(1)
-
-

5. Textured spherical spiral

+
+

5. Textured spherical spiral

-
+

spiral, 5.png

@@ -749,11 +749,11 @@ a$ = INPUT$(1)
-
-

6. Textured and shaded spherical spiral

+
+

6. Textured and shaded spherical spiral

-
+

spiral, 6.png

@@ -937,7 +937,7 @@ yStep2 = (oppositePointY2 - oppositePointY1) / stepCount
-

Created: 2025-07-29 ti 00:24

+

Created: 2025-07-29 ti 03:07

Validate

diff --git a/2D GFX/Textures/index.html b/2D GFX/Textures/index.html index 5e1b02f..d8b7d55 100644 --- a/2D GFX/Textures/index.html +++ b/2D GFX/Textures/index.html @@ -3,10 +3,10 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + -Fractals +Algorithmic textures -
-

1. Circular waves

+
+

1. Circular waves

This QBasic program creates visually captivating circular wave @@ -272,49 +272,49 @@ algorithms can produce intricate and visually appealing results.

-
' Program to render circular wave patterns.
-' Algorithm was accidentally discovered while experimenting with sine function.
-'
-' This program is free software: released under Creative Commons Zero (CC0) license
-' by Svjatoslav Agejenko.
-' Email: svjatoslav@svjatoslav.eu
-' Homepage: http://www.svjatoslav.eu
-'
-' Changelog:
-' 2003, Initial version
-' 2025, Improved program readability
-
-SCREEN 13
-
-' Initialize the screen mode to 320x200 with 16 colors
-
-' Outer loop for the vertical axis (y-coordinate)
-FOR ycoordinate = 1 TO 199
-    ' Inner loop for the horizontal axis (x-coordinate)
-    FOR xcoordinate = 1 TO 319
-        ' Calculate the sine value based on the squared distances from the origin
-        colorvalue = SIN((xcoordinate ^ 2 + ycoordinate ^ 2) / 10) * 10
-
-        ' Clamp the color value to the range [0, 15]
-        IF colorvalue < 0 THEN colorvalue = 0
-        IF colorvalue > 15 THEN colorvalue = 15
-
-        ' Set the pixel color at (xcoordinate, ycoordinate) with an offset to use the full 16-color palette
-        PSET (xcoordinate, ycoordinate), colorvalue + 16
-    NEXT xcoordinate
-NEXT ycoordinate
-
-' Wait for user key press
-WHILE INKEY$ = "": WEND
-CLS
-END
+
' Program to render circular wave patterns.
+' Algorithm was accidentally discovered while experimenting with sine function.
+'
+' This program is free software: released under Creative Commons Zero (CC0) license
+' by Svjatoslav Agejenko.
+' Email: svjatoslav@svjatoslav.eu
+' Homepage: http://www.svjatoslav.eu
+'
+' Changelog:
+' 2003, Initial version
+' 2025, Improved program readability
+
+SCREEN 13
+
+' Initialize the screen mode to 320x200 with 16 colors
+
+' Outer loop for the vertical axis (y-coordinate)
+FOR ycoordinate = 1 TO 199
+    ' Inner loop for the horizontal axis (x-coordinate)
+    FOR xcoordinate = 1 TO 319
+        ' Calculate the sine value based on the squared distances from the origin
+        colorvalue = SIN((xcoordinate ^ 2 + ycoordinate ^ 2) / 10) * 10
+
+        ' Clamp the color value to the range [0, 15]
+        IF colorvalue < 0 THEN colorvalue = 0
+        IF colorvalue > 15 THEN colorvalue = 15
+
+        ' Set the pixel color at (xcoordinate, ycoordinate) with an offset to use the full 16-color palette
+        PSET (xcoordinate, ycoordinate), colorvalue + 16
+    NEXT xcoordinate
+NEXT ycoordinate
+
+' Wait for user key press
+WHILE INKEY$ = "": WEND
+CLS
+END
 
-
-

2. Diamond square clouds

+
+

2. Diamond square clouds

This QBasic program demonstrates the Diamond-Square algorithm, a @@ -329,108 +329,108 @@ textures in computer graphics.

-
DECLARE SUB DrawPixels (x1 AS INTEGER, y1 AS INTEGER, s AS INTEGER)
-' Program to render cloud surface using diamond square algorithm.
-'
-' This program is free software: released under Creative Commons Zero (CC0) license
-' by Svjatoslav Agejenko.
-' Email: svjatoslav@svjatoslav.eu
-' Homepage: http://www.svjatoslav.eu
-'
-' Changelog:
-' 2003.12, Initial version
-' 2024.08, Improved program readability
-
-DECLARE SUB DrawBox (x1 AS INTEGER, y1 AS INTEGER, s AS INTEGER)
-DECLARE SUB SetPalette ()
-DECLARE SUB InitializeProgram ()
-DEFINT A-Z
+
DECLARE SUB DrawPixels (x1 AS INTEGER, y1 AS INTEGER, s AS INTEGER)
+' Program to render cloud surface using diamond square algorithm.
+'
+' This program is free software: released under Creative Commons Zero (CC0) license
+' by Svjatoslav Agejenko.
+' Email: svjatoslav@svjatoslav.eu
+' Homepage: http://www.svjatoslav.eu
+'
+' Changelog:
+' 2003.12, Initial version
+' 2024.08, Improved program readability
+
+DECLARE SUB DrawBox (x1 AS INTEGER, y1 AS INTEGER, s AS INTEGER)
+DECLARE SUB SetPalette ()
+DECLARE SUB InitializeProgram ()
+DEFINT A-Z
 InitializeProgram
 
-DIM SHARED maxLightness AS INTEGER
+DIM SHARED maxLightness AS INTEGER
 maxLightness = 127
 
-DIM scale AS INTEGER
+DIM scale AS INTEGER
 scale = 2 ^ 8
 
-1 :
+1 :
 scale = scale \ 2
 x1 = (319 \ scale) - 1
 y1 = (199 \ scale) - 1
 
-FOR y = 0 TO y1
-    FOR x = 0 TO x1
+FOR y = 0 TO y1
+    FOR x = 0 TO x1
         DrawPixels x * scale, y * scale, scale
-    NEXT x
-NEXT y
+    NEXT x
+NEXT y
 
-IF scale > 2 THEN GOTO 1
-WAITa$ = INPUT$(1)
+IF scale > 2 THEN GOTO 1
+WAITa$ = INPUT$(1)
 
-SUB DrawPixels (x1 AS INTEGER, y1 AS INTEGER, s AS INTEGER)
-    ' Get the lightness values for the corners of the box
-    c1 = POINT(x1, y1)
-    c2 = POINT(x1 + s, y1)
-    c3 = POINT(x1, y1 + s)
-    c4 = POINT(x1 + s, y1 + s)
+SUB DrawPixels (x1 AS INTEGER, y1 AS INTEGER, s AS INTEGER)
+    ' Get the lightness values for the corners of the box
+    c1 = POINT(x1, y1)
+    c2 = POINT(x1 + s, y1)
+    c3 = POINT(x1, y1 + s)
+    c4 = POINT(x1 + s, y1 + s)
 
-    ' Calculate the midpoint lightness values
+    ' Calculate the midpoint lightness values
     sp = s \ 2
     k = s * 2
     kp = k / 2
 
-    cc2 = ((c1 + c2) / 2) + (RND * k) - kp
-    IF cc2 > maxLightness THEN cc2 = maxLightness
-    IF cc2 < 0 THEN cc2 = 0
-
-    cc3 = ((c1 + c3) / 2) + (RND * k) - kp
-    IF cc3 > maxLightness THEN cc3 = maxLightness
-    IF cc3 < 0 THEN cc3 = 0
-
-    cc4 = ((c2 + c4) / 2) + (RND * k) - kp
-    IF cc4 > maxLightness THEN cc4 = maxLightness
-    IF cc4 < 0 THEN cc4 = 0
-
-    cc5 = ((c3 + c4) / 2) + (RND * k) - kp
-    IF cc5 > maxLightness THEN cc5 = maxLightness
-    IF cc5 < 0 THEN cc5 = 0
-
-    ' Calculate the central lightness value
-    cc1 = ((cc2 + cc3 + cc4 + cc5) / 4) + (RND * k) - kp
-    IF cc1 > maxLightness THEN cc1 = maxLightness
-    IF cc1 < 0 THEN cc1 = 0
-
-    ' Set the calculated lightness values for the box
-    PSET (x1 + sp, y1 + sp), cc1
-    PSET (x1 + sp, y1), cc2
-    PSET (x1, y1 + sp), cc3
-    PSET (x1 + s, y1 + sp), cc4
-    PSET (x1 + sp, y1 + s), cc5
-END SUB
-
-SUB InitializeProgram
-    ' Set the screen mode and initialize the color palette
-    SCREEN 13
+    cc2 = ((c1 + c2) / 2) + (RND * k) - kp
+    IF cc2 > maxLightness THEN cc2 = maxLightness
+    IF cc2 < 0 THEN cc2 = 0
+
+    cc3 = ((c1 + c3) / 2) + (RND * k) - kp
+    IF cc3 > maxLightness THEN cc3 = maxLightness
+    IF cc3 < 0 THEN cc3 = 0
+
+    cc4 = ((c2 + c4) / 2) + (RND * k) - kp
+    IF cc4 > maxLightness THEN cc4 = maxLightness
+    IF cc4 < 0 THEN cc4 = 0
+
+    cc5 = ((c3 + c4) / 2) + (RND * k) - kp
+    IF cc5 > maxLightness THEN cc5 = maxLightness
+    IF cc5 < 0 THEN cc5 = 0
+
+    ' Calculate the central lightness value
+    cc1 = ((cc2 + cc3 + cc4 + cc5) / 4) + (RND * k) - kp
+    IF cc1 > maxLightness THEN cc1 = maxLightness
+    IF cc1 < 0 THEN cc1 = 0
+
+    ' Set the calculated lightness values for the box
+    PSET (x1 + sp, y1 + sp), cc1
+    PSET (x1 + sp, y1), cc2
+    PSET (x1, y1 + sp), cc3
+    PSET (x1 + s, y1 + sp), cc4
+    PSET (x1 + sp, y1 + s), cc5
+END SUB
+
+SUB InitializeProgram
+    ' Set the screen mode and initialize the color palette
+    SCREEN 13
     SetPalette
-    RANDOMIZE TIMER
-END SUB
-
-SUB SetPalette
-    ' Set the color palette for lightness levels
-    FOR a = 0 TO 255
-        OUT &H3C8, a
-        OUT &H3C9, a / 4
-        OUT &H3C9, a / 3
-        OUT &H3C9, a / 2.3
-    NEXT a
-END SUB
+    RANDOMIZE TIMER
+END SUB
+
+SUB SetPalette
+    ' Set the color palette for lightness levels
+    FOR a = 0 TO 255
+        OUT &H3C8, a
+        OUT &H3C9, a / 4
+        OUT &H3C9, a / 3
+        OUT &H3C9, a / 2.3
+    NEXT a
+END SUB
 
-
-

3. Old paper

+
+

3. Old paper

This QBasic program generates a procedural texture that simulates the @@ -458,77 +458,77 @@ randomness, mimicking the fibrous texture of paper.

-
' Program to render surface resembling old paper.
-'
-' This program is free software: released under Creative Commons Zero (CC0) license
-' by Svjatoslav Agejenko.
-' Email: svjatoslav@svjatoslav.eu
-' Homepage: http://www.svjatoslav.eu
-'
-' Changelog:
-' 2003, Initial version
-' 2025, Improved program readability
-
-DEFINT A-Z
-SCREEN 13
-RANDOMIZE TIMER
-
-' Initialize the color palette to grayscale. Each color index from 0 to 63 has R, G, B values equal to the index,
-' creating a smooth grayscale gradient for the 256-color mode.
-FOR paletteIndex = 0 TO 63
-    OUT &H3C8, paletteIndex
-    OUT &H3C9, paletteIndex  ' Set red component
-    OUT &H3C9, paletteIndex  ' Set green component
-    OUT &H3C9, paletteIndex  ' Set blue component
-NEXT paletteIndex
+
' Program to render surface resembling old paper.
+'
+' This program is free software: released under Creative Commons Zero (CC0) license
+' by Svjatoslav Agejenko.
+' Email: svjatoslav@svjatoslav.eu
+' Homepage: http://www.svjatoslav.eu
+'
+' Changelog:
+' 2003, Initial version
+' 2025, Improved program readability
+
+DEFINT A-Z
+SCREEN 13
+RANDOMIZE TIMER
+
+' Initialize the color palette to grayscale. Each color index from 0 to 63 has R, G, B values equal to the index,
+' creating a smooth grayscale gradient for the 256-color mode.
+FOR paletteIndex = 0 TO 63
+    OUT &H3C8, paletteIndex
+    OUT &H3C9, paletteIndex  ' Set red component
+    OUT &H3C9, paletteIndex  ' Set green component
+    OUT &H3C9, paletteIndex  ' Set blue component
+NEXT paletteIndex
 
 noiseOffset = 0
 
-' Generate a paper-like surface by averaging the color of the pixel above with some randomness.
-' This creates a procedural texture that mimics the roughness of paper.
-FOR y = 1 TO 190
-    FOR x = 1 TO 310
+' Generate a paper-like surface by averaging the color of the pixel above with some randomness.
+' This creates a procedural texture that mimics the roughness of paper.
+FOR y = 1 TO 190
+    FOR x = 1 TO 310
         stepCounter = stepCounter + 1
 
-        ' Approximately every 10 steps, introduce a new random noise offset to create variation in the pattern.
-        ' This prevents the surface from becoming too uniform.
-        IF stepCounter > 10 THEN
-            noiseOffset = RND * currentColor / 20
-            stepCounter = stepCounter - (RND * 20 + 10)
-        END IF
+        ' Approximately every 10 steps, introduce a new random noise offset to create variation in the pattern.
+        ' This prevents the surface from becoming too uniform.
+        IF stepCounter > 10 THEN
+            noiseOffset = RND * currentColor / 20
+            stepCounter = stepCounter - (RND * 20 + 10)
+        END IF
 
-        ' Get the color of the pixel directly above the current position.
-        topColor = POINT(x, y - 1)
+        ' Get the color of the pixel directly above the current position.
+        topColor = POINT(x, y - 1)
 
-        ' Calculate the current color as the average of the top color and the previous current color,
-        ' plus a small random noise and minus the noise offset. This creates a smooth transition with
-        ' controlled randomness.
-        currentColor = (topColor + currentColor) \ 2 + ((RND * 2) - noiseOffset)
+        ' Calculate the current color as the average of the top color and the previous current color,
+        ' plus a small random noise and minus the noise offset. This creates a smooth transition with
+        ' controlled randomness.
+        currentColor = (topColor + currentColor) \ 2 + ((RND * 2) - noiseOffset)
 
-        ' Clamp the color value to stay within the valid palette range (0 to 63).
-        IF currentColor < 0 THEN currentColor = 0
-        IF currentColor > 63 THEN currentColor = 63
+        ' Clamp the color value to stay within the valid palette range (0 to 63).
+        IF currentColor < 0 THEN currentColor = 0
+        IF currentColor > 63 THEN currentColor = 63
 
-        ' Plot the current pixel at (x-1, y) using the calculated color.
-        PSET (x - 1, y), currentColor
-    NEXT x
+        ' Plot the current pixel at (x-1, y) using the calculated color.
+        PSET (x - 1, y), currentColor
+    NEXT x
 
-    ' Set the starting color for the next row to the last calculated color of the current row.
-    ' This ensures continuity between rows.
-    PSET (0, y + 1), currentColor
-NEXT y
+    ' Set the starting color for the next row to the last calculated color of the current row.
+    ' This ensures continuity between rows.
+    PSET (0, y + 1), currentColor
+NEXT y
 
-' Wait for a single key press before exiting the program.
-inputKey$ = INPUT$(1)
+' Wait for a single key press before exiting the program.
+inputKey$ = INPUT$(1)
 
-SYSTEM
+SYSTEM
 
-
-

4. Wood

+
+

4. Wood

This QBasic program creates a visually appealing simulation of a wood @@ -542,88 +542,88 @@ using simple graphical techniques.

-
' Program to render surface resembling wood.
-'
-' This program is free software: released under Creative Commons Zero (CC0) license
-' by Svjatoslav Agejenko.
-' Email: svjatoslav@svjatoslav.eu
-' Homepage: http://www.svjatoslav.eu
-'
-' Changelog:
-' 2003.12, Initial version
-' 2024 - 2025, Improved program readability
-
-DECLARE SUB DrawWoodSurface (woodX%, woodY%)
-DECLARE SUB DrawPaper (xPos%, y1Pos%)
-DEFINT A-Z
-SCREEN 12
-RANDOMIZE TIMER
-
-' Set palette colors
-FOR colorIndex = 0 TO 15
-    OUT &H3C8, colorIndex
-    OUT &H3C9, colorIndex * 4
-    OUT &H3C9, colorIndex * 3
-    OUT &H3C9, colorIndex * 0
-NEXT colorIndex
-
-' Main loop to draw wood at random positions
-100:
-woodX = RND * 400 + 200
-woodY = RND * 100 + 200
-CALL DrawWoodSurface(woodX, woodY)
-GOTO 100
-
-' Wait for user input to exit
-exitKey$ = INPUT$(1)
-
-SUB DrawWoodSurface (woodX, woodY)
-    DIM lowerY AS INTEGER
-    DIM phaseOffset AS INTEGER
-    DIM xStepCounter AS INTEGER
-    DIM randomOffset AS INTEGER
-    DIM newColor AS INTEGER
-    DIM upperColor AS INTEGER
-    DIM currentColor AS INTEGER
-
-    ' Draw the outline of the wood
+
' Program to render surface resembling wood.
+'
+' This program is free software: released under Creative Commons Zero (CC0) license
+' by Svjatoslav Agejenko.
+' Email: svjatoslav@svjatoslav.eu
+' Homepage: http://www.svjatoslav.eu
+'
+' Changelog:
+' 2003.12, Initial version
+' 2024 - 2025, Improved program readability
+
+DECLARE SUB DrawWoodSurface (woodX%, woodY%)
+DECLARE SUB DrawPaper (xPos%, y1Pos%)
+DEFINT A-Z
+SCREEN 12
+RANDOMIZE TIMER
+
+' Set palette colors
+FOR colorIndex = 0 TO 15
+    OUT &H3C8, colorIndex
+    OUT &H3C9, colorIndex * 4
+    OUT &H3C9, colorIndex * 3
+    OUT &H3C9, colorIndex * 0
+NEXT colorIndex
+
+' Main loop to draw wood at random positions
+100:
+woodX = RND * 400 + 200
+woodY = RND * 100 + 200
+CALL DrawWoodSurface(woodX, woodY)
+GOTO 100
+
+' Wait for user input to exit
+exitKey$ = INPUT$(1)
+
+SUB DrawWoodSurface (woodX, woodY)
+    DIM lowerY AS INTEGER
+    DIM phaseOffset AS INTEGER
+    DIM xStepCounter AS INTEGER
+    DIM randomOffset AS INTEGER
+    DIM newColor AS INTEGER
+    DIM upperColor AS INTEGER
+    DIM currentColor AS INTEGER
+
+    ' Draw the outline of the wood
     lowerY = woodY + 1
-    LINE (0, 0)-(woodX, woodY), 0, BF  ' Black background
-    LINE (5, 5)-(woodX - 5, lowerY - 5), 8, BF  ' Gray wood outline
-    LINE (10, 10)-(woodX - 10, lowerY - 10), 15, BF  ' White inner highlight
+    LINE (0, 0)-(woodX, woodY), 0, BF  ' Black background
+    LINE (5, 5)-(woodX - 5, lowerY - 5), 8, BF  ' Gray wood outline
+    LINE (10, 10)-(woodX - 10, lowerY - 10), 15, BF  ' White inner highlight
 
-    ' Initialize random phase offset for color variation
-    phaseOffset = RND * 300
+    ' Initialize random phase offset for color variation
+    phaseOffset = RND * 300
 
-    ' Draw the wood texture
-    FOR y = woodY - 1 TO 0 STEP -1
-        FOR x = woodX - 1 TO 0 STEP -1
+    ' Draw the wood texture
+    FOR y = woodY - 1 TO 0 STEP -1
+        FOR x = woodX - 1 TO 0 STEP -1
             xStepCounter = xStepCounter + 1
-            IF xStepCounter > woodX THEN
-                randomOffset = RND * 13  ' Small random noise for texture variation
-                xStepCounter = SIN((y + phaseOffset) / 100) * woodX  ' Sine wave to create wavy grain pattern
-            END IF
-            upperColor = POINT(x, y + 1)  ' Get color from upper pixel
-            currentColor = POINT(x, y)    ' Get color from current pixel
-            newColor = (upperColor * 2 + currentColor + newColor * 3 + randomOffset) / 7 + RND * 1
-
-            ' Ensure color value is within the valid range (0-15)
-            IF newColor < 0 THEN newColor = 0
-            IF newColor > 15 THEN newColor = 15
-
-            ' Set the pixel color for the wood texture
-            PSET (x + 1, y), newColor
-        NEXT x
-    NEXT y
-
-END SUB
+            IF xStepCounter > woodX THEN
+                randomOffset = RND * 13  ' Small random noise for texture variation
+                xStepCounter = SIN((y + phaseOffset) / 100) * woodX  ' Sine wave to create wavy grain pattern
+            END IF
+            upperColor = POINT(x, y + 1)  ' Get color from upper pixel
+            currentColor = POINT(x, y)    ' Get color from current pixel
+            newColor = (upperColor * 2 + currentColor + newColor * 3 + randomOffset) / 7 + RND * 1
+
+            ' Ensure color value is within the valid range (0-15)
+            IF newColor < 0 THEN newColor = 0
+            IF newColor > 15 THEN newColor = 15
+
+            ' Set the pixel color for the wood texture
+            PSET (x + 1, y), newColor
+        NEXT x
+    NEXT y
+
+END SUB
 
-
-

5. Yellow flame

+
+

5. Yellow flame

"Yellow Flame" is a visually captivating program written in QBasic @@ -650,59 +650,59 @@ natural, flickering effect.

-
' Yellow flame.
-'
-' This program is free software: released under Creative Commons Zero (CC0) license
-' by Svjatoslav Agejenko.
-' Email: svjatoslav@svjatoslav.eu
-' Homepage: http://www.svjatoslav.eu
-'
-' Changelog:
-' 2003.12, Initial version
-' 2024.08, Improved program readability
-
-
-DEFINT A-Z ' Define all variables as integers
-SCREEN 13 ' Set graphics mode to 320x200 with 256 colors
-RANDOMIZE TIMER ' Seed the random number generator
-
-' Initialize palette registers with sine wave colors
-FOR paletteIndex = 0 TO 255
-    OUT &H3C8, paletteIndex
-    OUT &H3C9, INT(SIN(paletteIndex / 21) * 30 + 30)
-    OUT &H3C9, INT(SIN(paletteIndex / 34) * 30 + 30)
-    OUT &H3C9, INT(SIN(paletteIndex / 10) * 30 + 30)
-NEXT paletteIndex
-
-' Generate the surface pattern
-FOR y = 1 TO 199
-    FOR x = 1 TO 319
-        prevPixel = POINT(x, y - 1)
-        leftPixel = POINT(x - 1, y)
-        diagPixel = POINT(x - 1, y - 1)
-        left2Pixel = POINT(x - 2, y)
-
-        ' Calculate the average of surrounding pixels and add some randomness
-        newColor = (prevPixel + leftPixel + diagPixel + left2Pixel) \ 4 + (RND * 5 - 2)
-
-        ' Clamp the color value within the valid range
-        IF newColor < 0 THEN newColor = 0
-        IF newColor > 63 THEN newColor = 63
-
-        ' Set the pixel with the calculated color
-        PSET (x, y), newColor
-    NEXT x
-NEXT y
-
-' Wait for user input to exit
-userInput$ = INPUT$(1)
+
' Yellow flame.
+'
+' This program is free software: released under Creative Commons Zero (CC0) license
+' by Svjatoslav Agejenko.
+' Email: svjatoslav@svjatoslav.eu
+' Homepage: http://www.svjatoslav.eu
+'
+' Changelog:
+' 2003.12, Initial version
+' 2024.08, Improved program readability
+
+
+DEFINT A-Z ' Define all variables as integers
+SCREEN 13 ' Set graphics mode to 320x200 with 256 colors
+RANDOMIZE TIMER ' Seed the random number generator
+
+' Initialize palette registers with sine wave colors
+FOR paletteIndex = 0 TO 255
+    OUT &H3C8, paletteIndex
+    OUT &H3C9, INT(SIN(paletteIndex / 21) * 30 + 30)
+    OUT &H3C9, INT(SIN(paletteIndex / 34) * 30 + 30)
+    OUT &H3C9, INT(SIN(paletteIndex / 10) * 30 + 30)
+NEXT paletteIndex
+
+' Generate the surface pattern
+FOR y = 1 TO 199
+    FOR x = 1 TO 319
+        prevPixel = POINT(x, y - 1)
+        leftPixel = POINT(x - 1, y)
+        diagPixel = POINT(x - 1, y - 1)
+        left2Pixel = POINT(x - 2, y)
+
+        ' Calculate the average of surrounding pixels and add some randomness
+        newColor = (prevPixel + leftPixel + diagPixel + left2Pixel) \ 4 + (RND * 5 - 2)
+
+        ' Clamp the color value within the valid range
+        IF newColor < 0 THEN newColor = 0
+        IF newColor > 63 THEN newColor = 63
+
+        ' Set the pixel with the calculated color
+        PSET (x, y), newColor
+    NEXT x
+NEXT y
+
+' Wait for user input to exit
+userInput$ = INPUT$(1)
 
-

Created: 2025-07-29 ti 02:13

+

Created: 2025-07-29 ti 03:07

Validate

diff --git a/3D GFX/3D Synthezier/doc/index.html b/3D GFX/3D Synthezier/doc/index.html index 47264a5..dbe3e1e 100644 --- a/3D GFX/3D Synthezier/doc/index.html +++ b/3D GFX/3D Synthezier/doc/index.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + 3D Synthezier @@ -1103,39 +1103,39 @@ hsAddReviewPanels();

Table of Contents

@@ -1157,8 +1157,8 @@ hsAddReviewPanels(); -
-

1. Operating principle

+
+

1. Operating principle

Parses scene definition language and creates 3D world based on @@ -1221,60 +1221,60 @@ They were produced by importing generated -

1.1. Rectangular city

+
+

1.1. Rectangular city

-
+

rectangular city, 1.jpeg

-
+

rectangular city, 2.jpeg

-
+

rectangular city, 3.jpeg

-
-

1.2. Hexagonal city

+
+

1.2. Hexagonal city

-
+

hexagonal city, 1.jpeg

-
+

hexagonal city, 2.jpeg

-
+

hexagonal city, 3.jpeg

-
-

2. Scene description language

+
+

2. Scene description language

See also examples.

-
-

2.1. here

+
+

2.1. here

 here
@@ -1285,8 +1285,8 @@ defines new segment
 

-
-

2.2. p

+
+

2.2. p

 p  x y z
@@ -1297,8 +1297,8 @@ defines new point
 

-
-

2.3. f

+
+

2.3. f

 f  p1 p2 p3 p4
@@ -1309,8 +1309,8 @@ defines new polygon,  p4  may be unused
 

-
-

2.4. warn

+
+

2.4. warn

 warn  <message>
@@ -1321,8 +1321,8 @@ displays warning message, and wait for key
 

-
-

2.5. end

+
+

2.5. end

 end
@@ -1333,8 +1333,8 @@ terminates parser
 

-
-

2.6. mtl

+
+

2.6. mtl

 mtl  material
@@ -1345,8 +1345,8 @@ selects material
 

-
-

2.7. mtlrnd

+
+

2.7. mtlrnd

 mtlrnd  material ...
@@ -1357,8 +1357,8 @@ selects random material from list
 

-
-

2.8. obj

+
+

2.8. obj

 obj  object xz45 xy20 x+3 y*2
@@ -1373,14 +1373,14 @@ directly from file, and not chached, to allow loading of greater than
 

-
+

rotation.png

-
-

2.9. rnd

+
+

2.9. rnd

 rnd  p^1^2^3 p^7^2^1
@@ -1391,8 +1391,8 @@ select random command to execute, ^ will be converted to spaces.
 

-
-

2.10. #

+
+

2.10. #

 # whatever text
@@ -1403,8 +1403,8 @@ comment
 

-
-

2.11. out

+
+

2.11. out

 out  file
@@ -1415,8 +1415,8 @@ specify output file name, must be first command
 

-
-

2.12. set

+
+

2.12. set

 set  variable  contents
@@ -1428,8 +1428,8 @@ string. max variables is 100. first is 0.
 

-
-

2.13. variables usage

+
+

2.13. variables usage

 anycommand %1 anything
@@ -1440,8 +1440,8 @@ inserts variable 1 contents info line
 

-
-

2.14. cmp

+
+

2.14. cmp

 cmp  flag string1 string2
@@ -1452,8 +1452,8 @@ compares strings, and inserts TRUE to flag, if they are equal, else inserts FALS
 

-
-

2.15. ?

+
+

2.15. ?

 ?flag anycommand
@@ -1468,8 +1468,8 @@ exapmle: ?3 obj car z*2 xy45
 

-
-

2.16. dum

+
+

2.16. dum

 dum
@@ -1482,16 +1482,16 @@ dummy function, does notheing
 
-
-

3. Installation

+
+

3. Installation

Edit bin/3dparse.bas file and update include path in there.

-
-

3.1. System requirements

+
+

3.1. System requirements

@@ -1522,8 +1522,8 @@ Edit bin/3dparse.bas file and update include path in there. -
-

3.2. Directory layout

+
+

3.2. Directory layout

bin
@@ -1540,8 +1540,8 @@ Edit bin/3dparse.bas file and update include path in there.
-
-

4. Usage

+
+

4. Usage

Make sure you have QB binaries in your PATH. Execute @@ -1566,7 +1566,7 @@ Visualize scene with your favourite renderer.

-

Created: 2025-07-29 ti 00:25

+

Created: 2025-07-29 ti 03:08

Validate

diff --git a/3D GFX/Miscellaneous/index.html b/3D GFX/Miscellaneous/index.html index 240ec9a..3a7c9d8 100644 --- a/3D GFX/Miscellaneous/index.html +++ b/3D GFX/Miscellaneous/index.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Miscellaneous 3D graphics demos @@ -210,14 +210,14 @@

Table of Contents

@@ -238,8 +238,8 @@ } -
-

1. Rotating exclamation mark

+
+

1. Rotating exclamation mark

Wireframe 3D model of a rotating exclamation mark. @@ -258,12 +258,13 @@ Wireframe 3D model of a rotating exclamation mark.

- -
-

2. 3D bouncing ball

+
+

2. 3D bouncing ball

-3D ball made of point cloud. +This QBasic program creates a visually engaging 3D animation of a +point-cloud ball bouncing around the screen. The program is an example +of early computer graphics techniques.

@@ -279,9 +280,8 @@ Wireframe 3D model of a rotating exclamation mark.
- -
-

3. 3D text in a room

+
+

3. 3D text in a room

Wireframe 3D text hanging in a wireframe 3D room. User can look and @@ -301,9 +301,8 @@ fly around in all directions.

- -
-

4. 3D bouncing cubes on grid floor

+
+

4. 3D bouncing cubes on grid floor

3D wireframe cubes bouncing on a grid floor, creating an immersive and @@ -323,9 +322,8 @@ dynamic visual effect.

- -
-

5. Matrix math for rotation in 3D space

+
+

5. Matrix math for rotation in 3D space

Instead of combining simple 2D rotors, pixels in this 3D space are @@ -345,16 +343,19 @@ rotated by using matrix multiplications.

- -
-

6. Maze explorer

+
+

6. Maze explorer

-TODO: add description +The Evolving 3D Maze Explorer is a QBasic program that generates and +navigates through a dynamically evolving 3D maze. This program is an +excellent example of early 3D graphics programming and provides an +interactive experience where users can explore a maze that grows and +changes as they navigate through it.

-
+

Maze%20explorer.png

@@ -365,8 +366,8 @@ TODO: add description
-
-

7. Tank animation

+
+

7. Tank animation

Animated tank driving through the bridge back and forward. User can @@ -386,9 +387,8 @@ look and fly around in all directions.

- -
-

8. Tiled room

+
+

8. Tiled room

Room with some tiles on the wall and on the floor. User can freely fly @@ -409,7 +409,7 @@ around.

-

Created: 2025-07-29 ti 00:25

+

Created: 2025-07-29 ti 03:08

Validate

diff --git a/3D GFX/Space/index.html b/3D GFX/Space/index.html index 17ca24a..8d5e261 100644 --- a/3D GFX/Space/index.html +++ b/3D GFX/Space/index.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Space themed 3D graphics @@ -210,10 +210,10 @@

Table of Contents

@@ -234,15 +234,18 @@ } -
-

1. Galaxy explorer

+
+

1. Galaxy explorer

-TODO: add description +This QBasic program renders a navigable 3D point cloud galaxy, +allowing users to explore a virtual galaxy using mouse or keyboard +controls. The program creates a visually engaging simulation of a +galaxy with stars distributed in a spiral pattern.

-
+

Galaxy%20explorer.png

@@ -253,12 +256,14 @@ TODO: add description
- -
-

2. Rocket simulator

+
+

2. Rocket simulator

-TODO: add description +QBasic program that simulates the takeoff and flight of a rocket from +the surface of a planet. This program provides a simple yet engaging +3D visualization of a rocket's journey, allowing users to navigate and +observe the rocket's trajectory from various angles.

@@ -274,14 +279,34 @@ TODO: add description
- -
-

3. Stars

+
+

3. Stars

-TODO: add description +The 3D Starfield Simulation is a QBasic program that creates a +visually captivating simulation of a starfield in three +dimensions. This program is designed to render stars moving in space, +giving the illusion of flying through a galaxy.

+

+How the Program Works: +

+ +
+
Camera Rotation
The camera's rotation is calculated to give a +dynamic view of the starfield.
+
Star Movement
Each star's position is updated to simulate +movement through space. Stars that get too close to the viewer are +repositioned to the far distance to create an infinite starfield +effect.
+
Projection
The 3D coordinates of each star are projected onto a +2D screen using perspective projection, which scales the stars based +on their distance from the viewer.
+
Brightness and Color
The brightness of each star is adjusted +based on its distance, with closer stars appearing brighter.
+
+
-
-

4. Universe explorer

+
+

4. Universe explorer

-TODO: add description +This QBasic program that simulates a navigable 3D universe. Users can +freely fly through a dynamically generated universe composed of galaxy +clusters, galaxies, and stars. The program employs a clever algorithm +to manage the level of detail, dynamically increasing or decreasing +the complexity of the universe regions based on the user's +position. This ensures a reasonable quantity of stars is rendered at +any given time, optimizing performance and visual experience.

+

+What's in it for the Reader? +

+ +
+
Algorithm Insight
The program provides a practical example of +dynamic level-of-detail algorithms, which can be useful for anyone +interested in computer graphics, game development, or simulation +programming.
+ +
3D Navigation
It demonstrates how to implement a 3D navigation +system using basic input devices like a mouse and keyboard, offering +insights into handling user inputs for movement and interaction in a +3D space.
+ +
Procedural Generation
The universe is procedurally generated, +showcasing how to create complex structures like galaxies and star +systems algorithmically.
+ +
Performance Optimization
The program highlights techniques for +optimizing performance in resource-intensive applications, such as +limiting the number of rendered objects based on distance.
+
+ -
+

1.png

-
+

2.png

-
+

3.png

@@ -327,7 +382,7 @@ TODO: add description
-

Created: 2025-07-29 ti 00:25

+

Created: 2025-07-29 ti 03:08

Validate

diff --git a/Math/Plotting/index.html b/Math/Plotting/index.html new file mode 100644 index 0000000..1b42107 --- /dev/null +++ b/Math/Plotting/index.html @@ -0,0 +1,365 @@ + + + + + + + +Plotting + + + + + + +
+

Plotting

+ + + +
+

1. 2D graph

+
+

+The 2D Graph Plotter is a simple yet effective program written in +QBasic that allows users to plot mathematical functions on a +two-dimensional grid. This program is particularly useful for +visualizing mathematical functions and understanding their graphical +representations. +

+ +

+The main loop of the program calculates the y-value for each x-value +based on a user-defined mathematical function. +

+ + +
+

2D%20graph%20plot.png +

+
+ +

+Source code +

+
+
+ +
+

2. 3D graph

+
+

+The 3D Heightmap Explorer is a QBasic program designed to visualize +mathematical functions in three dimensions. It allows users to explore +various heightmaps by defining custom formulas and observing their +graphical representations. This program is particularly useful for +educational purposes, helping users understand complex mathematical +surfaces. +

+ +

+Users can navigate through the 3D space using keyboard controls to +move around and inspect the heightmap from different angles. +

+ +

+The core of the program is the formula subroutine, where users can +define their mathematical functions. Multiple example formulas are +provided, which can be enabled or disabled to create different visual +effects. +

+ +

+The program includes a grid system that helps users perceive the scale +and orientation of the 3D space. This includes background grids and a +central 3D cross to indicate the zero point. +

+ +

+The formula subroutine evaluates the user-defined mathematical +function to determine the height (Z-coordinate) of each point on the +grid. +

+ + +
+

3D%20graph.png +

+
+ +

+Source code +

+
+
+ +
+

3. Deriviative calculator

+
+

+This QBasic program is designed to compute and plot an arbitrary +mathematical function on a 2D graph. Additionally, it calculates and +plots the derivative of the function, providing a visual +representation of both the function and its rate of change. The +program is a great educational tool for those interested in +understanding how mathematical functions and their derivatives can be +visualized. +

+ + +
+

Deriviative%20calculator.png +

+
+ +

+Source code +

+
+
+ +
+

4. Sine and cosine table

+
+

+The SIN & COS Table Generator is a QBasic program designed to visually +plot the sine and cosine functions on a graphical screen. This program +is particularly useful for educational purposes, providing a clear +visual representation of these fundamental trigonometric functions. +

+ + +
+

Sine%20and%20cosine%20table.png +

+
+ +

+Source code +

+
+
+
+
+

Created: 2025-07-29 ti 03:29

+

Validate

+
+ + diff --git a/Math/Plotting/index.org b/Math/Plotting/index.org new file mode 100644 index 0000000..4607c8b --- /dev/null +++ b/Math/Plotting/index.org @@ -0,0 +1,104 @@ +#+TITLE: Plotting +#+LANGUAGE: en +#+LATEX_HEADER: \usepackage[margin=1.0in]{geometry} +#+LATEX_HEADER: \usepackage{parskip} +#+LATEX_HEADER: \usepackage[none]{hyphenat} + +#+OPTIONS: H:20 num:20 +#+OPTIONS: author:nil + +#+begin_export html + +#+end_export + +* 2D graph + +The 2D Graph Plotter is a simple yet effective program written in +QBasic that allows users to plot mathematical functions on a +two-dimensional grid. This program is particularly useful for +visualizing mathematical functions and understanding their graphical +representations. + +The main loop of the program calculates the y-value for each x-value +based on a user-defined mathematical function. + +#+attr_html: :class responsive-img +#+attr_latex: :width 1000px +[[file:2D%20graph%20plot.bas][file:2D%20graph%20plot.png]] + +[[file:2D%20graph%20plot.bas][Source code]] + +* 3D graph + +The 3D Heightmap Explorer is a QBasic program designed to visualize +mathematical functions in three dimensions. It allows users to explore +various heightmaps by defining custom formulas and observing their +graphical representations. This program is particularly useful for +educational purposes, helping users understand complex mathematical +surfaces. + +Users can navigate through the 3D space using keyboard controls to +move around and inspect the heightmap from different angles. + +The core of the program is the formula subroutine, where users can +define their mathematical functions. Multiple example formulas are +provided, which can be enabled or disabled to create different visual +effects. + +The program includes a grid system that helps users perceive the scale +and orientation of the 3D space. This includes background grids and a +central 3D cross to indicate the zero point. + +The formula subroutine evaluates the user-defined mathematical +function to determine the height (Z-coordinate) of each point on the +grid. + +#+attr_html: :class responsive-img +#+attr_latex: :width 1000px +[[file:3D%20graph.bas][file:3D%20graph.png]] + +[[file:3D%20graph.bas][Source code]] + +* Deriviative calculator + +This QBasic program is designed to compute and plot an arbitrary +mathematical function on a 2D graph. Additionally, it calculates and +plots the derivative of the function, providing a visual +representation of both the function and its rate of change. The +program is a great educational tool for those interested in +understanding how mathematical functions and their derivatives can be +visualized. + +#+attr_html: :class responsive-img +#+attr_latex: :width 1000px +[[file:Deriviative%20calculator.bas][file:Deriviative%20calculator.png]] + +[[file:Deriviative%20calculator.bas][Source code]] + +* Sine and cosine table + +The SIN & COS Table Generator is a QBasic program designed to visually +plot the sine and cosine functions on a graphical screen. This program +is particularly useful for educational purposes, providing a clear +visual representation of these fundamental trigonometric functions. + +#+attr_html: :class responsive-img +#+attr_latex: :width 1000px +[[file:Sine%20and%20cosine%20table.bas][file:Sine%20and%20cosine%20table.png]] + +[[file:Sine%20and%20cosine%20table.bas][Source code]] diff --git a/Math/Simulation/Explosion simulator.bas b/Math/Simulation/Explosion simulator.bas new file mode 100755 index 0000000..73fe672 --- /dev/null +++ b/Math/Simulation/Explosion simulator.bas @@ -0,0 +1,240 @@ +' Program to simulate shock waves propagation in gas. +' This program is free software: released under Creative Commons Zero (CC0) license +' by Svjatoslav Agejenko. +' Email: svjatoslav@svjatoslav.eu +' Homepage: http://www.svjatoslav.eu +' +' Changelog: +' 2003, Initial version +' 2024 - 2025, Improved program readability + +DECLARE SUB SetLocalPressure(xCoord!, yCoord!, pressureValue!) +DECLARE SUB DrawBoundaryLine(startX!, startY!, endX!, endY!) +DIM SHARED wallBoundary +wallBoundary = 9980 ' Special value indicating solid wall boundaries + +' Shared arrays for fluid simulation: +DIM SHARED pressureGrid(1 TO 100, 1 TO 100) ' Stores pressure values at each grid point +DIM SHARED horizontalVelocity(1 TO 100, 1 TO 100) ' Stores horizontal velocity components +DIM SHARED verticalVelocity(1 TO 100, 1 TO 100) ' Stores vertical velocity components +DIM SHARED horizontalPressureChange(1 TO 100, 1 TO 100) ' Stores x-direction pressure change at each grid point +DIM SHARED verticalPressureChange(1 TO 100, 1 TO 100) ' Stores y-direction pressure change at each grid point + +SCREEN 13 +PAINT (1, 1), 1 +SetupInitialConditions + +1 ' Main simulation loop + + ' Check if any key is pressed; if so, exit the program + IF INKEY$ <> "" THEN SYSTEM + + ' Display pressure values in a grid at the bottom of the screen. + FOR gridY = 2 TO 99 + FOR gridX = 2 TO 99 + IF pressureGrid(gridX, gridY) = wallBoundary THEN + ' Set velocities to zero for wall boundaries + horizontalVelocity(gridX - 1, gridY) = 0 + verticalVelocity(gridX, gridY - 1) = 0 + horizontalVelocity(gridX, gridY) = 0 + verticalVelocity(gridX, gridY) = 0 + GOTO 3 ' Skip further calculations for this grid point if it's a wall + END IF + + ' Apply gravitation by subtracting pressure from vertical speed + verticalVelocity(gridX, gridY) = verticalVelocity(gridX, gridY) - (pressureGrid(gridX, gridY) / 500) + + IF pressureGrid(gridX + 1, gridY) = wallBoundary THEN + horizontalVelocity(gridX, gridY) = 0 ' Set horizontal speed to zero if there's a wall to the right + GOTO 2 ' Skip further calculations for this grid point if there's a wall to the right + END IF + + ' Calculate x-direction speed based on pressure difference and previous speed + horizontalVelocity(gridX, gridY) = (pressureGrid(gridX + 1, gridY) - pressureGrid(gridX, gridY)) / 20 + horizontalVelocity(gridX, gridY) + +2 ' Label for skipping further calculations if there's a wall to the right + IF pressureGrid(gridX, gridY + 1) = wallBoundary THEN + verticalVelocity(gridX, gridY) = 0 ' Set vertical speed to zero if there's a wall below + GOTO 3 ' Skip further calculations for this grid point if there's a wall below + END IF + + ' Calculate y-direction speed based on pressure difference and previous speed + verticalVelocity(gridX, gridY) = (pressureGrid(gridX, gridY + 1) - pressureGrid(gridX, gridY)) / 20 + verticalVelocity(gridX, gridY) + +3 ' Label for skipping further calculations if there's a wall below or above + NEXT gridX + NEXT gridY + +4 ' Negative pressure correction loop + negativePressureFlag = 0 ' Initialize negative pressure flag to zero + FOR gridY = 2 TO 99 + FOR gridX = 2 TO 99 + pressureDifference = pressureGrid(gridX, gridY) + horizontalVelocity(gridX, gridY) + verticalVelocity(gridX, gridY) - horizontalVelocity(gridX - 1, gridY) - verticalVelocity(gridX, gridY - 1) + + IF pressureDifference = 0 OR ((pressureDifference < 0) AND (pressureDifference > -.0001)) THEN + ' If difference in pressure is zero or slightly negative, set speeds to zero + IF horizontalVelocity(gridX, gridY) < 0 THEN + horizontalVelocity(gridX, gridY) = 0 + END IF + IF verticalVelocity(gridX, gridY) < 0 THEN + verticalVelocity(gridX, gridY) = 0 + END IF + IF horizontalVelocity(gridX - 1, gridY) > 0 THEN + horizontalVelocity(gridX - 1, gridY) = 0 + END IF + IF verticalVelocity(gridX, gridY - 1) > 0 THEN + verticalVelocity(gridX, gridY - 1) = 0 + END IF + END IF + + ' If pressure difference is negative + IF pressureDifference < 0 THEN + IF horizontalVelocity(gridX, gridY) < 0 THEN + horizontalVelocity(gridX, gridY) = horizontalVelocity(gridX, gridY) / 1.5 ' Divide horizontal speed by 1.5 if negative + END IF + IF verticalVelocity(gridX, gridY) < 0 THEN + verticalVelocity(gridX, gridY) = verticalVelocity(gridX, gridY) / 1.5 ' Divide vertical speed by 1.5 if negative + END IF + IF horizontalVelocity(gridX - 1, gridY) > 0 THEN + horizontalVelocity(gridX - 1, gridY) = horizontalVelocity(gridX - 1, gridY) / 1.5 ' Divide horizontal speed by 1.5 if positive + END IF + IF verticalVelocity(gridX, gridY - 1) > 0 THEN + verticalVelocity(gridX, gridY - 1) = verticalVelocity(gridX, gridY - 1) / 1.5 ' Divide vertical speed by 1.5 if positive + END IF + negativePressureFlag = 1 ' Set negative pressure flag to one + ' Display negative pressure value at the bottom of the screen + LOCATE 20, 1 + PRINT pressureDifference + END IF + NEXT gridX + NEXT gridY + + IF negativePressureFlag = 1 THEN GOTO 4 ' If negative pressure was detected, repeat this loop to correct speeds + +' Update pressure based on velocity +FOR gridY = 2 TO 99 + FOR gridX = 2 TO 99 + ' Update pressure based on speed in the x-direction + IF horizontalVelocity(gridX, gridY) > 0 THEN + horizontalPressureChange(gridX - 1, gridY) = ((pressureGrid(gridX, gridY) * horizontalVelocity(gridX - 1, gridY)) + (horizontalVelocity(gridX, gridY) * horizontalVelocity(gridX, gridY))) / (pressureGrid(gridX, gridY) + horizontalVelocity(gridX, gridY)) - horizontalVelocity(gridX - 1, gridY) + END IF + + ' Update pressure based on speed in the y-direction + IF verticalVelocity(gridX, gridY) > 0 THEN + verticalPressureChange(gridX, gridY - 1) = ((pressureGrid(gridX, gridY) * verticalVelocity(gridX, gridY - 1)) + (verticalVelocity(gridX, gridY) * verticalVelocity(gridX, gridY))) / (pressureGrid(gridX, gridY) + verticalVelocity(gridX, gridY)) - verticalVelocity(gridX, gridY - 1) + END IF + + ' Handle negative speeds in the x-direction + IF horizontalVelocity(gridX - 1, gridY) < 0 THEN + horizontalPressureChange(gridX, gridY) = ((pressureGrid(gridX, gridY) * horizontalVelocity(gridX, gridY)) - (horizontalVelocity(gridX - 1, gridY) * horizontalVelocity(gridX - 1, gridY))) / (pressureGrid(gridX, gridY) - horizontalVelocity(gridX - 1, gridY)) - horizontalVelocity(gridX, gridY) + END IF + + ' Handle negative speeds in the y-direction + IF verticalVelocity(gridX, gridY - 1) < 0 THEN + verticalPressureChange(gridX, gridY) = ((pressureGrid(gridX, gridY) * verticalVelocity(gridX, gridY)) - (verticalVelocity(gridX, gridY - 1) * verticalVelocity(gridX, gridY - 1))) / (pressureGrid(gridX, gridY) - verticalVelocity(gridX, gridY - 1)) - verticalVelocity(gridX, gridY) + END IF + NEXT gridX +NEXT gridY + +' Update pressure grid based on velocities +FOR gridY = 2 TO 99 + FOR gridX = 2 TO 99 + ' Update pressure based on speed in the x-direction + pressureGrid(gridX + 1, gridY) = pressureGrid(gridX + 1, gridY) - horizontalVelocity(gridX, gridY) + + ' Update pressure based on speed in the y-direction + pressureGrid(gridX, gridY + 1) = pressureGrid(gridX, gridY + 1) - verticalVelocity(gridX, gridY) + + ' Add x and y speeds to pressure + pressureGrid(gridX, gridY) = pressureGrid(gridX, gridY) + horizontalVelocity(gridX, gridY) + pressureGrid(gridX, gridY) = pressureGrid(gridX, gridY) + verticalVelocity(gridX, gridY) + NEXT gridX +NEXT gridY + +' Update velocities based on pressure changes +FOR gridY = 2 TO 99 + FOR gridX = 2 TO 99 + ' Update speed based on previous speed in the x-direction + horizontalVelocity(gridX, gridY) = horizontalVelocity(gridX, gridY) + horizontalPressureChange(gridX, gridY) + + ' Reset pressure change to zero for next iteration + horizontalPressureChange(gridX, gridY) = 0 + + ' Update speed based on previous speed in the y-direction + verticalVelocity(gridX, gridY) = verticalVelocity(gridX, gridY) + verticalPressureChange(gridX, gridY) + + ' Reset pressure change to zero for next iteration + verticalPressureChange(gridX, gridY) = 0 + NEXT gridX +NEXT gridY + +' Draw the grid based on pressure values +FOR gridY = 1 TO 100 + FOR gridX = 1 TO 100 + ' Draw pixel based on pressure value + PSET (gridX, gridY), pressureGrid(gridX, gridY) + 16 + NEXT gridX +NEXT gridY + +GOTO 1 ' Repeat the main simulation loop + +SUB DrawBoundaryLine (startX!, startY!, endX!, endY!) + ' Draws a straight line between two points in the pressure grid + ' All points along the line are set to wallBoundary value + ' Uses linear interpolation for smooth line drawing + maxSteps = ABS(startX - endX) + IF ABS(startY - endY) > maxSteps THEN maxSteps = ABS(startY - endY) + deltaX = endX - startX + deltaY = endY - startY + FOR stepCount = 0 TO maxSteps + ' Calculate interpolated coordinates + interpX = deltaX * stepCount / maxSteps + startX + interpY = deltaY * stepCount / maxSteps + startY + ' Mark this point as a wall boundary + pressureGrid(interpX, interpY) = wallBoundary + NEXT stepCount +END SUB + +SUB SetLocalPressure (xCoord!, yCoord!, pressureValue!) + ' Sets a 2x2 block of cells to specified pressure value + ' Creates localized pressure disturbances in simulation + pressureGrid(xCoord, yCoord) = pressureValue + pressureGrid(xCoord + 1, yCoord) = pressureValue + pressureGrid(xCoord, yCoord + 1) = pressureValue + pressureGrid(xCoord + 1, yCoord + 1) = pressureValue +END SUB + +SUB SetupInitialConditions + ' Sets up initial conditions for the simulation: + ' - Initializes all pressure and velocity arrays + ' - Places initial pressure disturbances + ' - Creates boundary walls + FOR yIndex = 1 TO 100 + FOR xIndex = 1 TO 100 + ' Initialize pressure and velocity variables + pressureGrid(xIndex, yIndex) = 3 + horizontalVelocity(xIndex, yIndex) = 0 + verticalVelocity(xIndex, yIndex) = 0 + horizontalPressureChange(xIndex, yIndex) = 0 + verticalPressureChange(xIndex, yIndex) = 0 + NEXT xIndex + NEXT yIndex + + ' Create initial pressure spots + FOR yIndex = 30 TO 60 + FOR xIndex = 10 TO 50 + SetLocalPressure xIndex, yIndex, 30 + NEXT xIndex + NEXT yIndex + + ' Draw boundary lines + DrawBoundaryLine 2, 2, 2, 99 + DrawBoundaryLine 99, 2, 99, 99 + DrawBoundaryLine 2, 99, 99, 99 + DrawBoundaryLine 2, 2, 99, 2 + + ' Draw additional lines for testing + FOR xIndex = 5 TO 40 STEP 5 + DrawBoundaryLine xIndex, 80, xIndex + 50, 80 - xIndex + NEXT xIndex +END SUB diff --git a/Math/Simulation/Explosion simulator.png b/Math/Simulation/Explosion simulator.png new file mode 100644 index 0000000..80089b6 Binary files /dev/null and b/Math/Simulation/Explosion simulator.png differ diff --git a/Math/Simulation/Explosion/Explosion simulator.bas b/Math/Simulation/Explosion/Explosion simulator.bas deleted file mode 100755 index 73fe672..0000000 --- a/Math/Simulation/Explosion/Explosion simulator.bas +++ /dev/null @@ -1,240 +0,0 @@ -' Program to simulate shock waves propagation in gas. -' This program is free software: released under Creative Commons Zero (CC0) license -' by Svjatoslav Agejenko. -' Email: svjatoslav@svjatoslav.eu -' Homepage: http://www.svjatoslav.eu -' -' Changelog: -' 2003, Initial version -' 2024 - 2025, Improved program readability - -DECLARE SUB SetLocalPressure(xCoord!, yCoord!, pressureValue!) -DECLARE SUB DrawBoundaryLine(startX!, startY!, endX!, endY!) -DIM SHARED wallBoundary -wallBoundary = 9980 ' Special value indicating solid wall boundaries - -' Shared arrays for fluid simulation: -DIM SHARED pressureGrid(1 TO 100, 1 TO 100) ' Stores pressure values at each grid point -DIM SHARED horizontalVelocity(1 TO 100, 1 TO 100) ' Stores horizontal velocity components -DIM SHARED verticalVelocity(1 TO 100, 1 TO 100) ' Stores vertical velocity components -DIM SHARED horizontalPressureChange(1 TO 100, 1 TO 100) ' Stores x-direction pressure change at each grid point -DIM SHARED verticalPressureChange(1 TO 100, 1 TO 100) ' Stores y-direction pressure change at each grid point - -SCREEN 13 -PAINT (1, 1), 1 -SetupInitialConditions - -1 ' Main simulation loop - - ' Check if any key is pressed; if so, exit the program - IF INKEY$ <> "" THEN SYSTEM - - ' Display pressure values in a grid at the bottom of the screen. - FOR gridY = 2 TO 99 - FOR gridX = 2 TO 99 - IF pressureGrid(gridX, gridY) = wallBoundary THEN - ' Set velocities to zero for wall boundaries - horizontalVelocity(gridX - 1, gridY) = 0 - verticalVelocity(gridX, gridY - 1) = 0 - horizontalVelocity(gridX, gridY) = 0 - verticalVelocity(gridX, gridY) = 0 - GOTO 3 ' Skip further calculations for this grid point if it's a wall - END IF - - ' Apply gravitation by subtracting pressure from vertical speed - verticalVelocity(gridX, gridY) = verticalVelocity(gridX, gridY) - (pressureGrid(gridX, gridY) / 500) - - IF pressureGrid(gridX + 1, gridY) = wallBoundary THEN - horizontalVelocity(gridX, gridY) = 0 ' Set horizontal speed to zero if there's a wall to the right - GOTO 2 ' Skip further calculations for this grid point if there's a wall to the right - END IF - - ' Calculate x-direction speed based on pressure difference and previous speed - horizontalVelocity(gridX, gridY) = (pressureGrid(gridX + 1, gridY) - pressureGrid(gridX, gridY)) / 20 + horizontalVelocity(gridX, gridY) - -2 ' Label for skipping further calculations if there's a wall to the right - IF pressureGrid(gridX, gridY + 1) = wallBoundary THEN - verticalVelocity(gridX, gridY) = 0 ' Set vertical speed to zero if there's a wall below - GOTO 3 ' Skip further calculations for this grid point if there's a wall below - END IF - - ' Calculate y-direction speed based on pressure difference and previous speed - verticalVelocity(gridX, gridY) = (pressureGrid(gridX, gridY + 1) - pressureGrid(gridX, gridY)) / 20 + verticalVelocity(gridX, gridY) - -3 ' Label for skipping further calculations if there's a wall below or above - NEXT gridX - NEXT gridY - -4 ' Negative pressure correction loop - negativePressureFlag = 0 ' Initialize negative pressure flag to zero - FOR gridY = 2 TO 99 - FOR gridX = 2 TO 99 - pressureDifference = pressureGrid(gridX, gridY) + horizontalVelocity(gridX, gridY) + verticalVelocity(gridX, gridY) - horizontalVelocity(gridX - 1, gridY) - verticalVelocity(gridX, gridY - 1) - - IF pressureDifference = 0 OR ((pressureDifference < 0) AND (pressureDifference > -.0001)) THEN - ' If difference in pressure is zero or slightly negative, set speeds to zero - IF horizontalVelocity(gridX, gridY) < 0 THEN - horizontalVelocity(gridX, gridY) = 0 - END IF - IF verticalVelocity(gridX, gridY) < 0 THEN - verticalVelocity(gridX, gridY) = 0 - END IF - IF horizontalVelocity(gridX - 1, gridY) > 0 THEN - horizontalVelocity(gridX - 1, gridY) = 0 - END IF - IF verticalVelocity(gridX, gridY - 1) > 0 THEN - verticalVelocity(gridX, gridY - 1) = 0 - END IF - END IF - - ' If pressure difference is negative - IF pressureDifference < 0 THEN - IF horizontalVelocity(gridX, gridY) < 0 THEN - horizontalVelocity(gridX, gridY) = horizontalVelocity(gridX, gridY) / 1.5 ' Divide horizontal speed by 1.5 if negative - END IF - IF verticalVelocity(gridX, gridY) < 0 THEN - verticalVelocity(gridX, gridY) = verticalVelocity(gridX, gridY) / 1.5 ' Divide vertical speed by 1.5 if negative - END IF - IF horizontalVelocity(gridX - 1, gridY) > 0 THEN - horizontalVelocity(gridX - 1, gridY) = horizontalVelocity(gridX - 1, gridY) / 1.5 ' Divide horizontal speed by 1.5 if positive - END IF - IF verticalVelocity(gridX, gridY - 1) > 0 THEN - verticalVelocity(gridX, gridY - 1) = verticalVelocity(gridX, gridY - 1) / 1.5 ' Divide vertical speed by 1.5 if positive - END IF - negativePressureFlag = 1 ' Set negative pressure flag to one - ' Display negative pressure value at the bottom of the screen - LOCATE 20, 1 - PRINT pressureDifference - END IF - NEXT gridX - NEXT gridY - - IF negativePressureFlag = 1 THEN GOTO 4 ' If negative pressure was detected, repeat this loop to correct speeds - -' Update pressure based on velocity -FOR gridY = 2 TO 99 - FOR gridX = 2 TO 99 - ' Update pressure based on speed in the x-direction - IF horizontalVelocity(gridX, gridY) > 0 THEN - horizontalPressureChange(gridX - 1, gridY) = ((pressureGrid(gridX, gridY) * horizontalVelocity(gridX - 1, gridY)) + (horizontalVelocity(gridX, gridY) * horizontalVelocity(gridX, gridY))) / (pressureGrid(gridX, gridY) + horizontalVelocity(gridX, gridY)) - horizontalVelocity(gridX - 1, gridY) - END IF - - ' Update pressure based on speed in the y-direction - IF verticalVelocity(gridX, gridY) > 0 THEN - verticalPressureChange(gridX, gridY - 1) = ((pressureGrid(gridX, gridY) * verticalVelocity(gridX, gridY - 1)) + (verticalVelocity(gridX, gridY) * verticalVelocity(gridX, gridY))) / (pressureGrid(gridX, gridY) + verticalVelocity(gridX, gridY)) - verticalVelocity(gridX, gridY - 1) - END IF - - ' Handle negative speeds in the x-direction - IF horizontalVelocity(gridX - 1, gridY) < 0 THEN - horizontalPressureChange(gridX, gridY) = ((pressureGrid(gridX, gridY) * horizontalVelocity(gridX, gridY)) - (horizontalVelocity(gridX - 1, gridY) * horizontalVelocity(gridX - 1, gridY))) / (pressureGrid(gridX, gridY) - horizontalVelocity(gridX - 1, gridY)) - horizontalVelocity(gridX, gridY) - END IF - - ' Handle negative speeds in the y-direction - IF verticalVelocity(gridX, gridY - 1) < 0 THEN - verticalPressureChange(gridX, gridY) = ((pressureGrid(gridX, gridY) * verticalVelocity(gridX, gridY)) - (verticalVelocity(gridX, gridY - 1) * verticalVelocity(gridX, gridY - 1))) / (pressureGrid(gridX, gridY) - verticalVelocity(gridX, gridY - 1)) - verticalVelocity(gridX, gridY) - END IF - NEXT gridX -NEXT gridY - -' Update pressure grid based on velocities -FOR gridY = 2 TO 99 - FOR gridX = 2 TO 99 - ' Update pressure based on speed in the x-direction - pressureGrid(gridX + 1, gridY) = pressureGrid(gridX + 1, gridY) - horizontalVelocity(gridX, gridY) - - ' Update pressure based on speed in the y-direction - pressureGrid(gridX, gridY + 1) = pressureGrid(gridX, gridY + 1) - verticalVelocity(gridX, gridY) - - ' Add x and y speeds to pressure - pressureGrid(gridX, gridY) = pressureGrid(gridX, gridY) + horizontalVelocity(gridX, gridY) - pressureGrid(gridX, gridY) = pressureGrid(gridX, gridY) + verticalVelocity(gridX, gridY) - NEXT gridX -NEXT gridY - -' Update velocities based on pressure changes -FOR gridY = 2 TO 99 - FOR gridX = 2 TO 99 - ' Update speed based on previous speed in the x-direction - horizontalVelocity(gridX, gridY) = horizontalVelocity(gridX, gridY) + horizontalPressureChange(gridX, gridY) - - ' Reset pressure change to zero for next iteration - horizontalPressureChange(gridX, gridY) = 0 - - ' Update speed based on previous speed in the y-direction - verticalVelocity(gridX, gridY) = verticalVelocity(gridX, gridY) + verticalPressureChange(gridX, gridY) - - ' Reset pressure change to zero for next iteration - verticalPressureChange(gridX, gridY) = 0 - NEXT gridX -NEXT gridY - -' Draw the grid based on pressure values -FOR gridY = 1 TO 100 - FOR gridX = 1 TO 100 - ' Draw pixel based on pressure value - PSET (gridX, gridY), pressureGrid(gridX, gridY) + 16 - NEXT gridX -NEXT gridY - -GOTO 1 ' Repeat the main simulation loop - -SUB DrawBoundaryLine (startX!, startY!, endX!, endY!) - ' Draws a straight line between two points in the pressure grid - ' All points along the line are set to wallBoundary value - ' Uses linear interpolation for smooth line drawing - maxSteps = ABS(startX - endX) - IF ABS(startY - endY) > maxSteps THEN maxSteps = ABS(startY - endY) - deltaX = endX - startX - deltaY = endY - startY - FOR stepCount = 0 TO maxSteps - ' Calculate interpolated coordinates - interpX = deltaX * stepCount / maxSteps + startX - interpY = deltaY * stepCount / maxSteps + startY - ' Mark this point as a wall boundary - pressureGrid(interpX, interpY) = wallBoundary - NEXT stepCount -END SUB - -SUB SetLocalPressure (xCoord!, yCoord!, pressureValue!) - ' Sets a 2x2 block of cells to specified pressure value - ' Creates localized pressure disturbances in simulation - pressureGrid(xCoord, yCoord) = pressureValue - pressureGrid(xCoord + 1, yCoord) = pressureValue - pressureGrid(xCoord, yCoord + 1) = pressureValue - pressureGrid(xCoord + 1, yCoord + 1) = pressureValue -END SUB - -SUB SetupInitialConditions - ' Sets up initial conditions for the simulation: - ' - Initializes all pressure and velocity arrays - ' - Places initial pressure disturbances - ' - Creates boundary walls - FOR yIndex = 1 TO 100 - FOR xIndex = 1 TO 100 - ' Initialize pressure and velocity variables - pressureGrid(xIndex, yIndex) = 3 - horizontalVelocity(xIndex, yIndex) = 0 - verticalVelocity(xIndex, yIndex) = 0 - horizontalPressureChange(xIndex, yIndex) = 0 - verticalPressureChange(xIndex, yIndex) = 0 - NEXT xIndex - NEXT yIndex - - ' Create initial pressure spots - FOR yIndex = 30 TO 60 - FOR xIndex = 10 TO 50 - SetLocalPressure xIndex, yIndex, 30 - NEXT xIndex - NEXT yIndex - - ' Draw boundary lines - DrawBoundaryLine 2, 2, 2, 99 - DrawBoundaryLine 99, 2, 99, 99 - DrawBoundaryLine 2, 99, 99, 99 - DrawBoundaryLine 2, 2, 99, 2 - - ' Draw additional lines for testing - FOR xIndex = 5 TO 40 STEP 5 - DrawBoundaryLine xIndex, 80, xIndex + 50, 80 - xIndex - NEXT xIndex -END SUB diff --git a/Math/Simulation/Explosion/index.html b/Math/Simulation/Explosion/index.html deleted file mode 100644 index e0410d6..0000000 --- a/Math/Simulation/Explosion/index.html +++ /dev/null @@ -1,17 +0,0 @@ - -explode - - - -

explode

-
-
-
Simulates air flow. -Air tries to spread equally around space, -while having is inertial farces, mass and gravitation. -Simulation animates shock waves propagation on -flat space after explosion. - -
- - \ No newline at end of file diff --git a/Math/Simulation/Explosion/screenshot.png b/Math/Simulation/Explosion/screenshot.png deleted file mode 100644 index 80089b6..0000000 Binary files a/Math/Simulation/Explosion/screenshot.png and /dev/null differ diff --git a/Math/Simulation/Interference.BAS b/Math/Simulation/Interference.BAS deleted file mode 100755 index 6252cf5..0000000 --- a/Math/Simulation/Interference.BAS +++ /dev/null @@ -1,51 +0,0 @@ -' Program simulates interference between two slightly different frequencies -' -' This program is free software: released under Creative Commons Zero (CC0) license -' by Svjatoslav Agejenko. -' Email: svjatoslav@svjatoslav.eu -' Homepage: http://www.svjatoslav.eu -' -' Changelog: -' ?, Initial version -' 2024-2025, Improved program readability - -DECLARE SUB GetFrequency () -DECLARE SUB Start () -DECLARE FUNCTION GetY! (t!) - -SCREEN 12 -1 - -' Check for user input and exit if any key is pressed -IF INKEY$ <> "" THEN SYSTEM - -frame = frame + 1 -FOR x = 0 TO 639 - - oldY1 = y1 - oldY2 = y2 - oldY3 = y3 - - ' Calculate new Y values for the waves - ' First wave: simple sine wave - y1 = SIN(frame + x / 4) * 20 + 150 - - ' Second wave: same but with additional phase shift that increases with x - ' This creates a slight frequency difference - y2 = SIN(frame + x / 4 + (x / 50)) * 20 + 150 - - ' Third line: sum of both waves to show interference pattern - y3 = y1 + y2 - - ' Clear the previous frame by drawing black vertical line - LINE (x, 0)-(x, 479), 0 - - ' Draw new lines for each wave - LINE (x - 1, oldY1)-(x, y1), 1 ' Blue wave - LINE (x - 1, oldY2)-(x, y2), 2 ' Green wave - LINE (x - 1, oldY3)-(x, y3), 15 ' White combined wave - -NEXT x -GOTO 1 - - diff --git a/Math/Simulation/Interference.bas b/Math/Simulation/Interference.bas new file mode 100755 index 0000000..6252cf5 --- /dev/null +++ b/Math/Simulation/Interference.bas @@ -0,0 +1,51 @@ +' Program simulates interference between two slightly different frequencies +' +' This program is free software: released under Creative Commons Zero (CC0) license +' by Svjatoslav Agejenko. +' Email: svjatoslav@svjatoslav.eu +' Homepage: http://www.svjatoslav.eu +' +' Changelog: +' ?, Initial version +' 2024-2025, Improved program readability + +DECLARE SUB GetFrequency () +DECLARE SUB Start () +DECLARE FUNCTION GetY! (t!) + +SCREEN 12 +1 + +' Check for user input and exit if any key is pressed +IF INKEY$ <> "" THEN SYSTEM + +frame = frame + 1 +FOR x = 0 TO 639 + + oldY1 = y1 + oldY2 = y2 + oldY3 = y3 + + ' Calculate new Y values for the waves + ' First wave: simple sine wave + y1 = SIN(frame + x / 4) * 20 + 150 + + ' Second wave: same but with additional phase shift that increases with x + ' This creates a slight frequency difference + y2 = SIN(frame + x / 4 + (x / 50)) * 20 + 150 + + ' Third line: sum of both waves to show interference pattern + y3 = y1 + y2 + + ' Clear the previous frame by drawing black vertical line + LINE (x, 0)-(x, 479), 0 + + ' Draw new lines for each wave + LINE (x - 1, oldY1)-(x, y1), 1 ' Blue wave + LINE (x - 1, oldY2)-(x, y2), 2 ' Green wave + LINE (x - 1, oldY3)-(x, y3), 15 ' White combined wave + +NEXT x +GOTO 1 + + diff --git a/Math/Simulation/Interferogram.BAS b/Math/Simulation/Interferogram.BAS deleted file mode 100755 index 1378bf9..0000000 --- a/Math/Simulation/Interferogram.BAS +++ /dev/null @@ -1,52 +0,0 @@ -' Program simulates lot of frequencies interfering with itself. -' As a result, interferogram is produced. -' -' This program is free software: released under Creative Commons Zero (CC0) license -' by Svjatoslav Agejenko. -' Email: svjatoslav@svjatoslav.eu -' Homepage: http://www.svjatoslav.eu -' -' Changelog: -' ?, Initial version -' 2024 - 2025, Improved program readability - -' Set graphics mode (640x480 with 16 colors) -SCREEN 12 - -' Start drawing from the leftmost pixel -PSET (0, 0) - -' Loop through all horizontal positions on screen -FOR currentXPosition = 0 TO 639 - - ' Calculate frequency scaling factor based on position - ' This creates a gradient effect in the interference pattern - frequencyScalingFactor = (currentXPosition - 320) / 5000 + 1 - - ' Initialize accumulated signal value - totalSignalValue = 0 - - ' Sample the signal at multiple time steps to calculate interference - FOR currentTimeStep = 1 TO 5000 STEP 5 - ' Generate two sine waves: - ' y1 - base frequency wave - ' y2 - frequency scaled wave (based on horizontal position) - baseWave = SIN(currentTimeStep) - scaledWave = SIN(currentTimeStep * frequencyScalingFactor) - - ' Calculate interference by summing the waves and taking absolute value - totalSignalValue = totalSignalValue + ABS(baseWave + scaledWave) - NEXT currentTimeStep - - ' Normalize the signal value - normalizedSignalValue = totalSignalValue / 5 - - ' Limit the value to screen boundaries - IF normalizedSignalValue > 470 THEN normalizedSignalValue = 470 - IF normalizedSignalValue < 0 THEN normalizedSignalValue = 0 - - ' Draw a line from previous position to current position - LINE -(currentXPosition, 479 - normalizedSignalValue), 15 - -NEXT currentXPosition - diff --git a/Math/Simulation/Interferogram.bas b/Math/Simulation/Interferogram.bas new file mode 100755 index 0000000..1378bf9 --- /dev/null +++ b/Math/Simulation/Interferogram.bas @@ -0,0 +1,52 @@ +' Program simulates lot of frequencies interfering with itself. +' As a result, interferogram is produced. +' +' This program is free software: released under Creative Commons Zero (CC0) license +' by Svjatoslav Agejenko. +' Email: svjatoslav@svjatoslav.eu +' Homepage: http://www.svjatoslav.eu +' +' Changelog: +' ?, Initial version +' 2024 - 2025, Improved program readability + +' Set graphics mode (640x480 with 16 colors) +SCREEN 12 + +' Start drawing from the leftmost pixel +PSET (0, 0) + +' Loop through all horizontal positions on screen +FOR currentXPosition = 0 TO 639 + + ' Calculate frequency scaling factor based on position + ' This creates a gradient effect in the interference pattern + frequencyScalingFactor = (currentXPosition - 320) / 5000 + 1 + + ' Initialize accumulated signal value + totalSignalValue = 0 + + ' Sample the signal at multiple time steps to calculate interference + FOR currentTimeStep = 1 TO 5000 STEP 5 + ' Generate two sine waves: + ' y1 - base frequency wave + ' y2 - frequency scaled wave (based on horizontal position) + baseWave = SIN(currentTimeStep) + scaledWave = SIN(currentTimeStep * frequencyScalingFactor) + + ' Calculate interference by summing the waves and taking absolute value + totalSignalValue = totalSignalValue + ABS(baseWave + scaledWave) + NEXT currentTimeStep + + ' Normalize the signal value + normalizedSignalValue = totalSignalValue / 5 + + ' Limit the value to screen boundaries + IF normalizedSignalValue > 470 THEN normalizedSignalValue = 470 + IF normalizedSignalValue < 0 THEN normalizedSignalValue = 0 + + ' Draw a line from previous position to current position + LINE -(currentXPosition, 479 - normalizedSignalValue), 15 + +NEXT currentXPosition + diff --git a/Math/Simulation/index.html b/Math/Simulation/index.html new file mode 100644 index 0000000..549a53d --- /dev/null +++ b/Math/Simulation/index.html @@ -0,0 +1,482 @@ + + + + + + + +Simulation + + + + + + +
+

Simulation

+ + + +
+

1. Explosion simulator

+
+

+This QBasic program simulates the propagation of shock waves in a gas +within a confined space. It models the behavior of pressure and +velocity in a two-dimensional grid, providing a visual representation +of how shock waves interact with boundaries and each other. +

+ +

+The program initializes a 100x100 grid to represent pressure and +velocity values. It sets up initial conditions, including placing +pressure disturbances and defining boundary walls. +

+ +

+The core of the program is a loop that continuously updates the +pressure and velocity values. The velocities in the horizontal and +vertical directions are updated based on pressure differences between +adjacent grid points. The program checks for and corrects negative +pressure values to ensure physical realism. The pressure grid is +updated based on the current velocities. The program handles boundary +conditions by setting velocities to zero at wall boundaries. +

+ + +
+

Explosion%20simulator.png +

+
+ +

+Source code +

+
+
+ +
+

2. Gravity in 2D

+
+

+The Gravitation Simulation program is a simple yet insightful QBasic +application that simulates the gravitational interaction between a +central mass and an orbiting object in a two-dimensional space. This +program provides a visual representation of how gravitational forces +influence the motion of celestial bodies, making it an excellent +educational tool for understanding basic orbital mechanics. +

+ + +
+

Gravity%20in%202D.png +

+
+ +

+Source code +

+
+
+ +
+

3. Gravity in 3D

+
+

+This QBasic program simulates the gravitational interactions between +spheres in a three-dimensional space. It provides a visual +representation of how spheres might move under the influence of +gravitational forces, offering an educational insight into basic +physics principles. +

+ +

+When spheres are far apart, gravity is dominating force. When Distance +between spheres crosses critical threshold, much stronger repulsive +force emerges and becomes dominant. +

+ +

+There is also friction. This ensures that after some bouncing, spheres +will reach stable configuration. +

+ +
+ +
+ +

+Source code +

+
+
+ +
+

4. Interference

+
+

+This QBasic program simulates the interference pattern created by two +sine waves with slightly different frequencies. It visually +demonstrates how wave interference works, which is a fundamental +concept in physics and engineering, particularly in the study of +sound, light, and other wave phenomena. +

+ +

+Program combines two waves to create an interference pattern, which is +displayed as a third waveform. +

+ +
+ +
+ +

+Source code +

+
+
+ +
+

5. Interferogram

+
+

+This QBasic program simulates the interference pattern created by +multiple frequencies interacting with each other. The result is a +visual representation known as an interferogram, which is commonly +used in physics and engineering to analyze wave interactions. +

+ + +
+

Interferogram.png +

+
+ +

+Source code +

+
+
+ +
+

6. Surface tension

+
+

+This QBasic program simulates the behavior of water spills and the +subsequent effects of surface tension using cellular automata +rules. The simulation models how water spreads and how surface tension +affects the shape of the water body, particularly smoothing out sharp +edges over time. +

+ +

+The main loop continuously calculates the next state of each cell +based on the surface tension rules. It uses the Moore neighborhood, +which includes all eight surrounding cells, to determine the state of +each cell in the next iteration. +

+ +

+The rules dictate that a water cell survives only if surrounded by a +moderate density of other water cells, while an empty space becomes a +water cell if surrounded by a high density of water cells. +

+ + +
+

Surface%20tension.png +

+
+ +

+Source code +

+
+
+ +
+

7. Wave 1

+
+

+This QBasic program simulates the propagation of waves across a +surface. It provides a visual representation of wave dynamics, which +can be both educational and a source of inspiration for those +interested in physics simulations or algorithmic art. +

+ +

+The program updates the velocity and height of each point based on the +calculated averages, applying a damping factor to simulate energy +loss. +

+ + +
+

Wave%201.png +

+
+ +

+Source code +

+
+
+ +
+

8. Wave 2

+
+

+This QBasic program simulates and visualizes the behavior of water +waves on a 2D surface. It creates a dynamic animation of water +disturbed by random rain droplets, demonstrating how waves propagate +and interact with each other. The program is an example of a simple +physics simulation and can serve as an educational tool for +understanding wave mechanics. +

+ + +
+

Wave%202.png +

+
+ +

+Source code +

+
+
+
+
+

Created: 2025-07-29 ti 03:58

+

Validate

+
+ + diff --git a/Math/Simulation/index.org b/Math/Simulation/index.org new file mode 100644 index 0000000..49824b6 --- /dev/null +++ b/Math/Simulation/index.org @@ -0,0 +1,183 @@ +#+TITLE: Simulation +#+LANGUAGE: en +#+LATEX_HEADER: \usepackage[margin=1.0in]{geometry} +#+LATEX_HEADER: \usepackage{parskip} +#+LATEX_HEADER: \usepackage[none]{hyphenat} + +#+OPTIONS: H:20 num:20 +#+OPTIONS: author:nil + +#+begin_export html + +#+end_export + +* Explosion simulator + +This QBasic program simulates the propagation of shock waves in a gas +within a confined space. It models the behavior of pressure and +velocity in a two-dimensional grid, providing a visual representation +of how shock waves interact with boundaries and each other. + +The program initializes a 100x100 grid to represent pressure and +velocity values. It sets up initial conditions, including placing +pressure disturbances and defining boundary walls. + +The core of the program is a loop that continuously updates the +pressure and velocity values. The velocities in the horizontal and +vertical directions are updated based on pressure differences between +adjacent grid points. The program checks for and corrects negative +pressure values to ensure physical realism. The pressure grid is +updated based on the current velocities. The program handles boundary +conditions by setting velocities to zero at wall boundaries. + +#+attr_html: :class responsive-img +#+attr_latex: :width 1000px +[[file:Explosion%20simulator.bas][file:Explosion%20simulator.png]] + +[[file:Explosion%20simulator.bas][Source code]] + +* Gravity in 2D + +The Gravitation Simulation program is a simple yet insightful QBasic +application that simulates the gravitational interaction between a +central mass and an orbiting object in a two-dimensional space. This +program provides a visual representation of how gravitational forces +influence the motion of celestial bodies, making it an excellent +educational tool for understanding basic orbital mechanics. + +#+attr_html: :class responsive-img +#+attr_latex: :width 1000px +[[file:Gravity%20in%202D.bas][file:Gravity%20in%202D.png]] + +[[file:Gravity%20in%202D.bas][Source code]] + +* Gravity in 3D + +This QBasic program simulates the gravitational interactions between +spheres in a three-dimensional space. It provides a visual +representation of how spheres might move under the influence of +gravitational forces, offering an educational insight into basic +physics principles. + +When spheres are far apart, gravity is dominating force. When Distance +between spheres crosses critical threshold, much stronger repulsive +force emerges and becomes dominant. + +There is also friction. This ensures that after some bouncing, spheres +will reach stable configuration. + +#+begin_export html +
+ +
+#+end_export + +[[file:Gravity%20in%203D.bas][Source code]] + +* Interference + +This QBasic program simulates the interference pattern created by two +sine waves with slightly different frequencies. It visually +demonstrates how wave interference works, which is a fundamental +concept in physics and engineering, particularly in the study of +sound, light, and other wave phenomena. + +Program combines two waves to create an interference pattern, which is +displayed as a third waveform. + +#+begin_export html +
+ +
+#+end_export + +[[file:Interference.bas][Source code]] + +* Interferogram + +This QBasic program simulates the interference pattern created by +multiple frequencies interacting with each other. The result is a +visual representation known as an interferogram, which is commonly +used in physics and engineering to analyze wave interactions. + +#+attr_html: :class responsive-img +#+attr_latex: :width 1000px +[[file:Interferogram.bas][file:Interferogram.png]] + +[[file:Interferogram.bas][Source code]] + +* Surface tension + +This QBasic program simulates the behavior of water spills and the +subsequent effects of surface tension using cellular automata +rules. The simulation models how water spreads and how surface tension +affects the shape of the water body, particularly smoothing out sharp +edges over time. + +The main loop continuously calculates the next state of each cell +based on the surface tension rules. It uses the Moore neighborhood, +which includes all eight surrounding cells, to determine the state of +each cell in the next iteration. + +The rules dictate that a water cell survives only if surrounded by a +moderate density of other water cells, while an empty space becomes a +water cell if surrounded by a high density of water cells. + +#+attr_html: :class responsive-img +#+attr_latex: :width 1000px +[[file:Surface%20tension.bas][file:Surface%20tension.png]] + +[[file:Surface%20tension.bas][Source code]] + +* Wave 1 + +This QBasic program simulates the propagation of waves across a +surface. It provides a visual representation of wave dynamics, which +can be both educational and a source of inspiration for those +interested in physics simulations or algorithmic art. + +The program updates the velocity and height of each point based on the +calculated averages, applying a damping factor to simulate energy +loss. + +#+attr_html: :class responsive-img +#+attr_latex: :width 1000px +[[file:Wave%201.bas][file:Wave%201.png]] + +[[file:Wave%201.bas][Source code]] + +* Wave 2 + +This QBasic program simulates and visualizes the behavior of water +waves on a 2D surface. It creates a dynamic animation of water +disturbed by random rain droplets, demonstrating how waves propagate +and interact with each other. The program is an example of a simple +physics simulation and can serve as an educational tool for +understanding wave mechanics. + +#+attr_html: :class responsive-img +#+attr_latex: :width 1000px +[[file:Wave%202.bas][file:Wave%202.png]] + +[[file:Wave%202.bas][Source code]] diff --git a/Tools/Update web site b/Tools/Update web site index 13994de..2e62d6d 100755 --- a/Tools/Update web site +++ b/Tools/Update web site @@ -36,6 +36,11 @@ export_org_to_html "3D GFX/3D Synthezier/doc" export_org_to_html "3D GFX/Miscellaneous" export_org_to_html "3D GFX/Space" +export_org_to_html "Math/Plotting" +export_org_to_html "Math/Simulation" +export_org_to_html "Math/Truth table" + + # Upload project homepage to the server. rsync -avz --delete -e 'ssh -p 10006' ./ \ --include="*/" \