+++ /dev/null
-' 3D math test.\r
-' By Svjatoslav Agejenko.\r
-' Email: svjatoslav@svjatoslav.eu\r
-' Homepage: http://www.svjatoslav.eu\r
-'\r
-' Changelog:\r
-' 2003.12, Initial version\r
-' 2024.08, Improved program readability using AI\r
-\r
-\r
-DECLARE SUB Star (xAsFloat, yAsFloat, zAsFloat, an1AsFloat, an2AsFloat, an3AsFloat)\r
-DECLARE SUB Gp (xAsFloat, yAsFloat, zAsFloat, x1AsFloat, y1AsFloat)\r
-DECLARE SUB Stic (xAsFloat, yAsFloat, zAsFloat, an1AsFloat, an2AsFloat, an3AsFloat)\r
-DECLARE SUB Gc (xAsFloat, yAsFloat, zAsFloat, x1AsFloat, y1AsFloat, z1AsFloat)\r
-DECLARE SUB Gcp (xAsFloat, yAsFloat, zAsFloat, x1AsFloat, y1AsFloat)\r
-DECLARE SUB Setan (alpAsFloat, betAsFloat, gamAsFloat)\r
-DECLARE SUB Start ()\r
-DECLARE SUB Drawscr ()\r
-\r
-DIM SHARED mx1AsFloat, my1AsFloat, mz1AsFloat\r
-DIM SHARED mx2AsFloat, my2AsFloat, mz2AsFloat\r
-DIM SHARED mx3AsFloat, my3AsFloat, mz3AsFloat\r
-\r
-DIM SHARED frmAsInteger, piAsDouble\r
-\r
-Start\r
-\r
-1\r
-\r
-Drawscr\r
-frmAsInteger = frmAsInteger + 1\r
-GOTO 1\r
-\r
-SUB Drawscr\r
-\r
-an1AsFloat = SIN(frmAsInteger / 50) / 2\r
-an2AsFloat = SIN(frmAsInteger / 23) / 2 - .5\r
-an3AsFloat = 0\r
-\r
-' Set the rotation angles\r
-Setan an1AsFloat, an2AsFloat, an3AsFloat\r
-\r
-FOR xAsInteger = -100 TO 100 STEP 10\r
- FOR zAsInteger = 0 TO 200 STEP 10\r
- Gcp xAsInteger, -90, zAsInteger, x1AsFloat, y1AsFloat\r
- PSET (x1AsFloat, y1AsFloat), 15\r
- NEXT zAsInteger\r
-NEXT xAsInteger\r
-\r
-Gc -70, -90, 150, x1AsFloat, y1AsFloat, z1AsFloat\r
-\r
-' Calculate star position and draw it\r
-Stic x1AsFloat, y1AsFloat, z1AsFloat, an1AsFloat, an2AsFloat, an3AsFloat\r
-\r
-' Copy screen and clear for the next frame\r
-PCOPY 0, 1\r
-CLS\r
-END SUB\r
-\r
-SUB Gc (xAsFloat, yAsFloat, zAsFloat, x1AsFloat, y1AsFloat, z1AsFloat)\r
-x1AsFloat = xAsFloat * mx1AsFloat + yAsFloat * my1AsFloat + zAsFloat * mz1AsFloat\r
-y1AsFloat = xAsFloat * mx2AsFloat + yAsFloat * my2AsFloat + zAsFloat * mz2AsFloat\r
-z1AsFloat = xAsFloat * mx3AsFloat + yAsFloat * my3AsFloat + zAsFloat * mz3AsFloat\r
-END SUB\r
-\r
-SUB Gcp (xAsFloat, yAsFloat, zAsFloat, x1AsFloat, y1AsFloat)\r
-\r
-rxAsFloat = xAsFloat * mx1AsFloat + yAsFloat * my1AsFloat + zAsFloat * mz1AsFloat ' Matrix transformation\r
-ryAsFloat = xAsFloat * mx2AsFloat + yAsFloat * my2AsFloat + zAsFloat * mz2AsFloat\r
-rzAsFloat = xAsFloat * mx3AsFloat + yAsFloat * my3AsFloat + zAsFloat * mz3AsFloat\r
-\r
-rzAsFloat = rzAsFloat + 100 ' Perspective calculation\r
-x1AsFloat = rxAsFloat / rzAsFloat * 120\r
-y1AsFloat = ryAsFloat / rzAsFloat * 120\r
-END SUB\r
-\r
-SUB Gp (xAsFloat, yAsFloat, zAsFloat, x1AsFloat, y1AsFloat)\r
-' Apply perspective calculation\r
-rzAsFloat = zAsFloat + 100\r
-x1AsFloat = xAsFloat / rzAsFloat * 120\r
-y1AsFloat = yAsFloat / rzAsFloat * 120\r
-END SUB\r
-\r
-SUB Setan (alpAsFloat, betAsFloat, gamAsFloat)\r
-' Calculate the rotation matrix\r
-mx1AsFloat = SIN(gamAsFloat) * SIN(betAsFloat) * SIN(alpAsFloat) + COS(gamAsFloat) * COS(alpAsFloat)\r
-my1AsFloat = COS(betAsFloat) * SIN(alpAsFloat)\r
-mz1AsFloat = SIN(gamAsFloat) * COS(alpAsFloat) - COS(gamAsFloat) * SIN(betAsFloat) * SIN(alpAsFloat)\r
-\r
-mx2AsFloat = SIN(gamAsFloat) * SIN(betAsFloat) * COS(alpAsFloat) - COS(gamAsFloat) * SIN(alpAsFloat)\r
-my2AsFloat = COS(betAsFloat) * COS(alpAsFloat)\r
-mz2AsFloat = -COS(gamAsFloat) * SIN(betAsFloat) * COS(alpAsFloat) - SIN(gamAsFloat) * SIN(alpAsFloat)\r
-\r
-mx3AsFloat = -SIN(gamAsFloat) * COS(betAsFloat)\r
-my3AsFloat = SIN(betAsFloat)\r
-mz3AsFloat = COS(gamAsFloat) * COS(betAsFloat)\r
-END SUB\r
-\r
-SUB Star (xAsFloat, yAsFloat, zAsFloat, an1AsFloat, an2AsFloat, an3AsFloat)\r
-' Calculate angles for the star points\r
-nan1AsFloat = an1AsFloat\r
-nan2AsFloat = an2AsFloat\r
-nan3AsFloat = an3AsFloat\r
-\r
-' Set the rotation angles\r
-Setan nan1AsFloat, nan2AsFloat, nan3AsFloat\r
-\r
-' Apply perspective transformation\r
-Gp xAsFloat, yAsFloat, zAsFloat, rx1AsFloat, ry1AsFloat\r
-\r
-FOR nAsInteger = 0 TO piAsDouble * 2 - .1 STEP piAsDouble / 5\r
- x1AsFloat = SIN(nAsInteger) * 20\r
- y1AsFloat = COS(nAsInteger) * 20\r
-\r
- ' Apply matrix transformation to the star point\r
- Gc x1AsFloat, y1AsFloat, 0, x2AsFloat, y2AsFloat, z2AsFloat\r
- Gp x2AsFloat + xAsFloat, y2AsFloat + yAsFloat, z2AsFloat + zAsFloat, rx2AsFloat, ry2AsFloat\r
-CIRCLE (rx2AsFloat, ry2AsFloat), 1, 14\r
-LINE (rx2AsFloat, ry2AsFloat)-(rx1AsFloat, ry1AsFloat), 1\r
-NEXT nAsInteger\r
-\r
-END SUB\r
-\r
-SUB Start\r
-' Set up the screen and window\r
-SCREEN 7, , , 1\r
-WINDOW (-160, -100)-(160, 100)\r
-\r
-piAsDouble = 3.141592\r
-\r
-END SUB\r
-\r
-SUB Stic (xAsFloat, yAsFloat, zAsFloat, an1AsFloat, an2AsFloat, an3AsFloat)\r
-' Calculate angles for the star points\r
-nan1AsFloat = an1AsFloat\r
-nan2AsFloat = an2AsFloat\r
-nan3AsFloat = an3AsFloat + frmAsInteger / 50\r
-\r
-' Set the rotation angles\r
-Setan nan1AsFloat, nan2AsFloat, nan3AsFloat\r
-\r
-' Apply perspective transformation\r
-Gp xAsFloat, yAsFloat, zAsFloat, rx1AsFloat, ry1AsFloat\r
-\r
-DIM tmpx(0 TO 5)\r
-DIM tmpy(0 TO 5)\r
-DIM tmpz(0 TO 5)\r
-\r
-DIM tmprx(0 TO 5)\r
-DIM tmpry(0 TO 5)\r
-pAsInteger = 0\r
-\r
-FOR nAsInteger = 0 TO piAsDouble * 2 - .5 STEP piAsDouble / 3\r
- x1AsFloat = SIN(nAsInteger) * 100\r
- z1AsFloat = COS(nAsInteger) * 100\r
-\r
- ' Apply matrix transformation to the star point\r
- Gc x1AsFloat, 100, z1AsFloat, x2AsFloat, y2AsFloat, z2AsFloat\r
- tmpx(pAsInteger) = x2AsFloat + xAsFloat\r
- tmpy(pAsInteger) = y2AsFloat + yAsFloat\r
- tmpz(pAsInteger) = z2AsFloat + zAsFloat\r
- Gp x2AsFloat + xAsFloat, y2AsFloat + yAsFloat, z2AsFloat + zAsFloat, rx2AsFloat, ry2AsFloat\r
- tmprx(pAsInteger) = rx2AsFloat\r
- tmpry(pAsInteger) = ry2AsFloat\r
- LINE (rx1AsFloat, ry1AsFloat)-(rx2AsFloat, ry2AsFloat), 15\r
-\r
- pAsInteger = pAsInteger + 1\r
-NEXT nAsInteger\r
-\r
-LINE (tmprx(0), tmpry(0))-(tmprx(2), tmpry(2)), 10\r
-LINE (tmprx(2), tmpry(2))-(tmprx(4), tmpry(4)), 10\r
-LINE (tmprx(4), tmpry(4))-(tmprx(0), tmpry(0)), 10\r
-\r
-LINE (tmprx(1), tmpry(1))-(tmprx(3), tmpry(3)), 12\r
-LINE (tmprx(3), tmpry(3))-(tmprx(5), tmpry(5)), 12\r
-LINE (tmprx(5), tmpry(5))-(tmprx(1), tmpry(1)), 12\r
-\r
-Star tmpx(0), tmpy(0), tmpz(0), nan1AsFloat, nan2AsFloat, nan3AsFloat\r
-\r
-END SUB\r
-\r