From: Svjatoslav Agejenko Date: Mon, 19 Aug 2024 09:32:49 +0000 (+0300) Subject: Using AI to improve code readability X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=commitdiff_plain;h=d203ab77a9127d2405770b1583f93e2be67659a3;p=qbasicapps.git Using AI to improve code readability --- diff --git a/Graphics/3D/3dlife.bas b/Graphics/3D/3dlife.bas index c00b2f6..d44a8f3 100755 --- a/Graphics/3D/3dlife.bas +++ b/Graphics/3D/3dlife.bas @@ -1,366 +1,337 @@ -DECLARE SUB ruut (x!, y!, z!) -' use: -' arrow keys - move around -' 2, 6, 4, 8 - look around -' - - fly up -' + - fly down - - - -DECLARE SUB mkkoll () -DECLARE SUB putkol () -DECLARE SUB rend () -DECLARE SUB env () -DECLARE SUB start () -DIM SHARED npo, nlo, np, nl -DIM SHARED px(1 TO 3000) -DIM SHARED py(1 TO 3000) -DIM SHARED pz(1 TO 3000) -DIM SHARED rpx(1 TO 7000) -DIM SHARED rpy(1 TO 7000) -DIM SHARED orpx(0 TO 9000) -DIM SHARED orpy(0 TO 9000) -DIM SHARED onp -DIM SHARED lin1(1 TO 3800) -DIM SHARED lin2(1 TO 3800) -DIM SHARED linc(1 TO 3800) -DIM SHARED olin1(1 TO 3800) -DIM SHARED olin2(1 TO 3800) -DIM SHARED onl -DIM SHARED myx, myy, myz -DIM SHARED myxs, myys, myzs -DIM SHARED an1, an2 -DIM SHARED an1s, an2s -DIM SHARED frm - -DIM SHARED life(1 TO 50, 1 TO 50) -DIM SHARED life2(1 TO 50, 1 TO 50) - - - -start -'env - -an1 = 1.5 -1 -frm = frm + 1 - -mkkoll -rend - -myx = SIN(frm / 20) * 12 -myy = SIN(frm / 50) * 10 + 15 -myz = COS(frm / 20) * 12 - -an1 = an1 - .05 -an2 = 2.2 + SIN(frm / 50) / 2 - -a$ = INKEY$ -IF a$ <> "" THEN - SYSTEM -END IF -GOTO 1 - -SUB env - -FOR z = -5 TO 5 -FOR x = -5 TO 5 -np = np + 1 -px(np) = x -py(np) = 0 -pz(np) = z -IF x > -5 THEN -nl = nl + 1 -lin1(nl) = np -lin2(nl) = np - 1 -linc(nl) = 1 -END IF -IF z > -5 THEN -nl = nl + 1 -lin1(nl) = np -lin2(nl) = np - 11 -linc(nl) = 1 -END IF -NEXT x -NEXT z - -npo = np -nlo = nl - - -END SUB - -SUB env1 - -np = 1 -px(np) = -2 -py(np) = 0 -pz(np) = 0 -np = np + 1 -px(np) = 2 -py(np) = 0 -pz(np) = 0 - -nl = 1 -lin1(nl) = 1 -lin2(nl) = 2 -linc(nl) = 14 - -END SUB - -SUB mkkoll -np = npo -nl = nlo +DECLARE SUB PlaceCube (x!, y!, z!) +DECLARE SUB DrawCube (x!, y!, z!) + +DECLARE SUB CreateCollisionData () +DECLARE SUB UpdateCollisionData () +DECLARE SUB RenderScene () +DECLARE SUB InitializeEnvironment () +DECLARE SUB StartGame () +DIM SHARED numPoints, numLines, pointCount, lineCount +DIM SHARED pointsX(1 TO 3000), pointsY(1 TO 3000), pointsZ(1 TO 3000) +DIM SHARED renderedPointsX(1 TO 7000), renderedPointsY(1 TO 7000) +DIM SHARED originalRenderedPointsX(0 TO 9000), originalRenderedPointsY(0 TO 9000) +DIM SHARED oldPointCount, oldLineCount +DIM SHARED lineVertices1(1 TO 3800), lineVertices2(1 TO 3800), lineColors(1 TO 3800) +DIM SHARED originalLineVertices1(1 TO 3800), originalLineVertices2(1 TO 3800) +DIM SHARED myPositionX, myPositionY, myPositionZ +DIM SHARED myPreviousPositionX, myPreviousPositionY, myPreviousPositionZ +DIM SHARED angle1, angle2 +DIM SHARED angle1Str, angle2Str +DIM SHARED frameCount + +DIM SHARED gameOfLifeGrid(1 TO 50, 1 TO 50) +DIM SHARED nextGameOfLifeGrid(1 TO 50, 1 TO 50) + +StartGame +' InitializeEnvironment + +angle1 = 1.5 +10 +frameCount = frameCount + 1 + +CreateCollisionData +RenderScene + +myPositionX = SIN(frameCount / 20) * 12 +myPositionY = SIN(frameCount / 50) * 10 + 15 +myPositionZ = COS(frameCount / 20) * 12 + +angle1 = angle1 - .05 +angle2 = 2.2 + SIN(frameCount / 50) / 2 + +inputKey$ = INKEY$ +IF inputKey$ <> "" THEN SYSTEM +GOTO 10 + +SUB CreateCollisionData +pointCount = numPoints +lineCount = numLines FOR y = 1 TO 50 FOR x = 1 TO 50 - IF life(x, y) = 1 THEN - v = ABS(x - 26) + ABS(y - 26) + frm - ruut x - 25, SIN(v / 5) * 5, y - 25 + IF gameOfLifeGrid(x, y) = 1 THEN + v = ABS(x - 26) + ABS(y - 26) + frameCount + PlaceCube x - 25, SIN(v / 5) * 5, y - 25 END IF NEXT x NEXT y - - -IF frm \ 10 = frm / 10 THEN +IF frameCount \ 10 = frameCount / 10 THEN FOR y = 2 TO 49 FOR x = 2 TO 49 -c = life(x - 1, y - 1) -c = c + life(x, y - 1) -c = c + life(x + 1, y - 1) -c = c + life(x - 1, y) -c = c + life(x + 1, y) -c = c + life(x - 1, y + 1) -c = c + life(x, y + 1) -c = c + life(x + 1, y + 1) - -IF life(x, y) = 1 THEN - IF (c > 3) OR (c < 2) THEN life2(x, y) = 0 ELSE life2(x, y) = 1 +c = gameOfLifeGrid(x - 1, y - 1) +c = c + gameOfLifeGrid(x, y - 1) +c = c + gameOfLifeGrid(x + 1, y - 1) +c = c + gameOfLifeGrid(x - 1, y) +c = c + gameOfLifeGrid(x + 1, y) +c = c + gameOfLifeGrid(x - 1, y + 1) +c = c + gameOfLifeGrid(x, y + 1) +c = c + gameOfLifeGrid(x + 1, y + 1) + +IF gameOfLifeGrid(x, y) = 1 THEN + IF (c > 3) OR (c < 2) THEN nextGameOfLifeGrid(x, y) = 0 ELSE nextGameOfLifeGrid(x, y) = 1 ELSE - IF c = 3 THEN life2(x, y) = 1 ELSE life2(x, y) = 0 + IF c = 3 THEN nextGameOfLifeGrid(x, y) = 1 ELSE nextGameOfLifeGrid(x, y) = 0 END IF NEXT x NEXT y - FOR y = 1 TO 50 FOR x = 1 TO 50 - life(x, y) = life2(x, y) + gameOfLifeGrid(x, y) = nextGameOfLifeGrid(x, y) NEXT x NEXT y END IF END SUB -SUB rend +SUB InitializeEnvironment +FOR z = -5 TO 5 +FOR x = -5 TO 5 +pointCount = pointCount + 1 +pointsX(pointCount) = x +pointsY(pointCount) = 0 +pointsZ(pointCount) = z +IF x > -5 THEN +lineCount = lineCount + 1 +lineVertices1(lineCount) = pointCount +lineVertices2(lineCount) = pointCount - 1 +lineColors(lineCount) = 1 +END IF +IF z > -5 THEN +lineCount = lineCount + 1 +lineVertices1(lineCount) = pointCount +lineVertices2(lineCount) = pointCount - 10 +lineColors(lineCount) = 1 +END IF +NEXT x +NEXT z + +numPoints = pointCount +numLines = lineCount + +END SUB + +SUB InitializeEnvironment1 +pointCount = 1 +pointsX(pointCount) = -2 +pointsY(pointCount) = 0 +pointsZ(pointCount) = 0 +pointCount = pointCount + 1 +pointsX(pointCount) = 2 +pointsY(pointCount) = 0 +pointsZ(pointCount) = 0 + +lineCount = 1 +lineVertices1(lineCount) = 1 +lineVertices2(lineCount) = 2 +lineColors(lineCount) = 14 + +END SUB + +SUB PlaceCube (x, y, z) + +v = 3 + +lineCount = lineCount + 1 +lineVertices1(lineCount) = pointCount + 1 +lineVertices2(lineCount) = pointCount + 2 +lineColors(lineCount) = v + +lineCount = lineCount + 1 +lineVertices1(lineCount) = pointCount + 2 +lineVertices2(lineCount) = pointCount + 3 +lineColors(lineCount) = v + +lineCount = lineCount + 1 +lineVertices1(lineCount) = pointCount + 3 +lineVertices2(lineCount) = pointCount + 4 +lineColors(lineCount) = v + +lineCount = lineCount + 1 +lineVertices1(lineCount) = pointCount + 4 +lineVertices2(lineCount) = pointCount + 1 +lineColors(lineCount) = v + +lineCount = lineCount + 1 +lineVertices1(lineCount) = pointCount + 5 +lineVertices2(lineCount) = pointCount + 6 +lineColors(lineCount) = v + +lineCount = lineCount + 1 +lineVertices1(lineCount) = pointCount + 6 +lineVertices2(lineCount) = pointCount + 7 +lineColors(lineCount) = v + +lineCount = lineCount + 1 +lineVertices1(lineCount) = pointCount + 7 +lineVertices2(lineCount) = pointCount + 8 +lineColors(lineCount) = v + +lineCount = lineCount + 1 +lineVertices1(lineCount) = pointCount + 8 +lineVertices2(lineCount) = pointCount + 5 +lineColors(lineCount) = v + +lineCount = lineCount + 1 +lineVertices1(lineCount) = pointCount + 1 +lineVertices2(lineCount) = pointCount + 5 +lineColors(lineCount) = v + +lineCount = lineCount + 1 +lineVertices1(lineCount) = pointCount + 2 +lineVertices2(lineCount) = pointCount + 6 +lineColors(lineCount) = v + +lineCount = lineCount + 1 +lineVertices1(lineCount) = pointCount + 3 +lineVertices2(lineCount) = pointCount + 7 +lineColors(lineCount) = v + +lineCount = lineCount + 1 +lineVertices1(lineCount) = pointCount + 4 +lineVertices2(lineCount) = pointCount + 8 +lineColors(lineCount) = v + +pointCount = pointCount + 1 +pointsX(pointCount) = x - .5 +pointsY(pointCount) = y +pointsZ(pointCount) = z - .5 + +pointCount = pointCount + 1 +pointsX(pointCount) = x + .5 +pointsY(pointCount) = y +pointsZ(pointCount) = z - .5 + +pointCount = pointCount + 1 +pointsX(pointCount) = x + .5 +pointsY(pointCount) = y +pointsZ(pointCount) = z + .5 + +pointCount = pointCount + 1 +pointsX(pointCount) = x - .5 +pointsY(pointCount) = y +pointsZ(pointCount) = z + .5 + +pointCount = pointCount + 1 +pointsX(pointCount) = x - .5 +pointsY(pointCount) = y + 1 +pointsZ(pointCount) = z - .5 + +pointCount = pointCount + 1 +pointsX(pointCount) = x + .5 +pointsY(pointCount) = y + 1 +pointsZ(pointCount) = z - .5 + +pointCount = pointCount + 1 +pointsX(pointCount) = x + .5 +pointsY(pointCount) = y + 1 +pointsZ(pointCount) = z + .5 + +pointCount = pointCount + 1 +pointsX(pointCount) = x - .5 +pointsY(pointCount) = y + 1 +pointsZ(pointCount) = z + .5 + +END SUB + +SUB RenderScene +sineAngle1 = SIN(angle1) +cosineAngle1 = COS(angle1) +sineAngle2 = SIN(angle2) +cosineAngle2 = COS(angle2) -s1 = SIN(an1) -c1 = COS(an1) -s2 = SIN(an2) -c2 = COS(an2) +FOR a = 1 TO pointCount +x = pointsX(a) + myPositionX +y = pointsY(a) - myPositionY +z = pointsZ(a) + myPositionZ + +x1 = x * sineAngle1 - z * cosineAngle1 +z1 = x * cosineAngle1 + z * sineAngle1 +y1 = y * sineAngle2 - z1 * cosineAngle2 +z2 = y * cosineAngle2 + z1 * sineAngle2 -FOR a = 1 TO np -x = px(a) + myx -y = py(a) - myy -z = pz(a) + myz - -x1 = x * s1 - z * c1 -z1 = x * c1 + z * s1 -y1 = y * s2 - z1 * c2 -z2 = y * c2 + z1 * s2 - IF z2 < .5 THEN -rpx(a) = -1 +renderedPointsX(a) = -1 ELSE -rpx(a) = 320 + (x1 / z2 * 400) -rpy(a) = 240 - (y1 / z2 * 400) +renderedPointsX(a) = 320 + (x1 / z2 * 400) +renderedPointsY(a) = 240 - (y1 / z2 * 400) END IF NEXT a - - -FOR a = 1 TO nl -l1 = olin1(a) -l2 = olin2(a) - -IF orpx(l1) = -1 OR orpx(l2) = -1 THEN ELSE LINE (orpx(l1), orpy(l1))-(orpx(l2), orpy(l2)), 0 -l1 = lin1(a) -l2 = lin2(a) -IF rpx(l1) = -1 OR rpx(l2) = -1 THEN ELSE LINE (rpx(l1), rpy(l1))-(rpx(l2), rpy(l2)), linc(a) -NEXT - -IF nl < onl THEN -FOR a = nl + 1 TO onl -l1 = olin1(a) -l2 = olin2(a) -IF orpx(l1) = -1 OR orpx(l2) = -1 THEN ELSE LINE (orpx(l1), orpy(l1))-(orpx(l2), orpy(l2)), 0 -NEXT -END IF -FOR a = 1 TO np -orpx(a) = rpx(a) -orpy(a) = rpy(a) -NEXT a -onp = np +FOR a = 1 TO lineCount +l1 = originalLineVertices1(a) +l2 = originalLineVertices2(a) -FOR a = 1 TO nl -olin1(a) = lin1(a) -olin2(a) = lin2(a) +IF originalRenderedPointsX(l1) = -1 OR originalRenderedPointsX(l2) = -1 THEN ELSE LINE (originalRenderedPointsX(l1), originalRenderedPointsY(l1))-(originalRenderedPointsX(l2), originalRenderedPointsY(l2)), 0 +l1 = lineVertices1(a) +l2 = lineVertices2(a) +IF renderedPointsX(l1) = -1 OR renderedPointsX(l2) = -1 THEN ELSE LINE (renderedPointsX(l1), renderedPointsY(l1))-(renderedPointsX(l2), renderedPointsY(l2)), lineColors(a) NEXT a -onl = nl - -END SUB -SUB ruut (x, y, z) - -v = 3 +IF lineCount < oldLineCount THEN +FOR a = lineCount + 1 TO oldLineCount +l1 = originalLineVertices1(a) +l2 = originalLineVertices2(a) +IF originalRenderedPointsX(l1) = -1 OR originalRenderedPointsX(l2) = -1 THEN ELSE LINE (originalRenderedPointsX(l1), originalRenderedPointsY(l1))-(originalRenderedPointsX(l2), originalRenderedPointsY(l2)), 0 +NEXT a +END IF -nl = nl + 1 -lin1(nl) = np + 1 -lin2(nl) = np + 2 -linc(nl) = v - -nl = nl + 1 -lin1(nl) = np + 2 -lin2(nl) = np + 3 -linc(nl) = v - -nl = nl + 1 -lin1(nl) = np + 3 -lin2(nl) = np + 4 -linc(nl) = v - -nl = nl + 1 -lin1(nl) = np + 4 -lin2(nl) = np + 1 -linc(nl) = v - -nl = nl + 1 -lin1(nl) = np + 5 -lin2(nl) = np + 6 -linc(nl) = v - -nl = nl + 1 -lin1(nl) = np + 6 -lin2(nl) = np + 7 -linc(nl) = v - -nl = nl + 1 -lin1(nl) = np + 7 -lin2(nl) = np + 8 -linc(nl) = v - -nl = nl + 1 -lin1(nl) = np + 8 -lin2(nl) = np + 5 -linc(nl) = v - -nl = nl + 1 -lin1(nl) = np + 1 -lin2(nl) = np + 5 -linc(nl) = v - -nl = nl + 1 -lin1(nl) = np + 2 -lin2(nl) = np + 6 -linc(nl) = v - -nl = nl + 1 -lin1(nl) = np + 3 -lin2(nl) = np + 7 -linc(nl) = v - -nl = nl + 1 -lin1(nl) = np + 4 -lin2(nl) = np + 8 -linc(nl) = v - -np = np + 1 -px(np) = x - .5 -py(np) = y -pz(np) = z - .5 - -np = np + 1 -px(np) = x + .5 -py(np) = y -pz(np) = z - .5 - -np = np + 1 -px(np) = x + .5 -py(np) = y -pz(np) = z + .5 - -np = np + 1 -px(np) = x - .5 -py(np) = y -pz(np) = z + .5 - - -np = np + 1 -px(np) = x - .5 -py(np) = y + 1 -pz(np) = z - .5 - -np = np + 1 -px(np) = x + .5 -py(np) = y + 1 -pz(np) = z - .5 - -np = np + 1 -px(np) = x + .5 -py(np) = y + 1 -pz(np) = z + .5 - -np = np + 1 -px(np) = x - .5 -py(np) = y + 1 -pz(np) = z + .5 +FOR a = 1 TO pointCount +originalRenderedPointsX(a) = renderedPointsX(a) +originalRenderedPointsY(a) = renderedPointsY(a) +NEXT a +oldPointCount = pointCount +FOR a = 1 TO lineCount +originalLineVertices1(a) = lineVertices1(a) +originalLineVertices2(a) = lineVertices2(a) +NEXT a +oldLineCount = lineCount END SUB -SUB start +SUB StartGame SCREEN 12 -npo = 0 -nlo = 0 -np = npo -nl = nlo -kolm = 50 - -myx = 4 -myy = 15 -myz = 17 -an1 = 3.14 / 2 - .29 -an2 = an1 + 1 +numPoints = 0 +numLines = 0 +pointCount = numPoints +lineCount = numLines +gridSize = 50 + +myPositionX = 4 +myPositionY = 15 +myPositionZ = 17 +angle1 = ATN(1) / 2 - .29 +angle2 = angle1 + 1 FOR a = 1 TO 1000 -linc(a) = 4 +lineColors(a) = 4 NEXT a FOR a = 1 TO 1000 -olin1(a) = 1 -olin2(a) = 1 +originalLineVertices1(a) = 1 +originalLineVertices2(a) = 1 NEXT a - OPEN "3dlife.dat" FOR INPUT AS #1 y = 20 -3 -IF EOF(1) <> 0 THEN GOTO 4 +20 +IF EOF(1) <> 0 THEN GOTO 30 x = 20 -LINE INPUT #1, a$ -FOR b = 1 TO LEN(a$) - c$ = RIGHT$(LEFT$(a$, b), 1) - IF c$ = "#" THEN life(x, y) = 1 +LINE INPUT #1, inputLine$ +FOR b = 1 TO LEN(inputLine$) + c$ = RIGHT$(LEFT$(inputLine$, b), 1) + IF c$ = "#" THEN gameOfLifeGrid(x, y) = 1 x = x + 1 NEXT b y = y + 1 -GOTO 3 -4 +GOTO 20 +30 CLOSE #1 END SUB diff --git a/Graphics/3D/3dtest.bas b/Graphics/3D/3dtest.bas index 0a62689..28ec08d 100755 --- a/Graphics/3D/3dtest.bas +++ b/Graphics/3D/3dtest.bas @@ -1,155 +1,157 @@ -' 3D test -' made by Svjatoslav Agejenko -' in 2003.12 -' H-Page: svjatoslav.eu -' E-Mail: svjatoslav@svjatoslav.eu - -DECLARE SUB star (x!, y!, z!, an1!, an2!, an3!) -DECLARE SUB gp (x!, y!, z!, x1!, y1!) -DECLARE SUB stic (x!, y!, z!, an1!, an2!, an3!) -DECLARE SUB gc (x!, y!, z!, x1!, y1!, z1!) -DECLARE SUB gcp (x!, y!, z!, x1!, y1!) -DECLARE SUB setan (alp!, bet!, gam!) -DECLARE SUB start () -DECLARE SUB drawscr () - -DIM SHARED mx1, my1, mz1 -DIM SHARED mx2, my2, mz2 -DIM SHARED mx3, my3, mz3 - -DIM SHARED frm, pi - -start +' 3D math test. +' By Svjatoslav Agejenko. +' Email: svjatoslav@svjatoslav.eu +' Homepage: http://www.svjatoslav.eu +' +' Changelog: +' 2003.12, Initial version +' 2024.08, Improved program readability using AI + + +DECLARE SUB Star (xAsFloat, yAsFloat, zAsFloat, an1AsFloat, an2AsFloat, an3AsFloat) +DECLARE SUB Gp (xAsFloat, yAsFloat, zAsFloat, x1AsFloat, y1AsFloat) +DECLARE SUB Stic (xAsFloat, yAsFloat, zAsFloat, an1AsFloat, an2AsFloat, an3AsFloat) +DECLARE SUB Gc (xAsFloat, yAsFloat, zAsFloat, x1AsFloat, y1AsFloat, z1AsFloat) +DECLARE SUB Gcp (xAsFloat, yAsFloat, zAsFloat, x1AsFloat, y1AsFloat) +DECLARE SUB Setan (alpAsFloat, betAsFloat, gamAsFloat) +DECLARE SUB Start () +DECLARE SUB Drawscr () + +DIM SHARED mx1AsFloat, my1AsFloat, mz1AsFloat +DIM SHARED mx2AsFloat, my2AsFloat, mz2AsFloat +DIM SHARED mx3AsFloat, my3AsFloat, mz3AsFloat + +DIM SHARED frmAsInteger, piAsDouble + +Start 1 -drawscr -frm = frm + 1 +Drawscr +frmAsInteger = frmAsInteger + 1 GOTO 1 -SUB drawscr - -an1 = SIN(frm / 50) / 2 -an2 = SIN(frm / 23) / 2 - .5 -an3 = 0 +SUB Drawscr -setan an1, an2, an3 +an1AsFloat = SIN(frmAsInteger / 50) / 2 +an2AsFloat = SIN(frmAsInteger / 23) / 2 - .5 +an3AsFloat = 0 -FOR x = -100 TO 100 STEP 10 - FOR z = 0 TO 200 STEP 10 - gcp x, -90, z, x1, y1 - PSET (x1, y1), 15 - NEXT z -NEXT x +Setan an1AsFloat, an2AsFloat, an3AsFloat -gc -70, -90, 150, x1, y1, z1 +FOR xAsInteger = -100 TO 100 STEP 10 + FOR zAsInteger = 0 TO 200 STEP 10 + Gcp xAsInteger, -90, zAsInteger, x1AsFloat, y1AsFloat + PSET (x1AsFloat, y1AsFloat), 15 + NEXT zAsInteger +NEXT xAsInteger -stic x1, y1, z1, an1, an2, an3 +Gc -70, -90, 150, x1AsFloat, y1AsFloat, z1AsFloat +Stic x1AsFloat, y1AsFloat, z1AsFloat, an1AsFloat, an2AsFloat, an3AsFloat PCOPY 0, 1 CLS END SUB -SUB gc (x, y, z, x1, y1, z1) -x1 = x * mx1 + y * my1 + z * mz1 -y1 = x * mx2 + y * my2 + z * mz2 -z1 = x * mx3 + y * my3 + z * mz3 +SUB Gc (xAsFloat, yAsFloat, zAsFloat, x1AsFloat, y1AsFloat, z1AsFloat) +x1AsFloat = xAsFloat * mx1AsFloat + yAsFloat * my1AsFloat + zAsFloat * mz1AsFloat +y1AsFloat = xAsFloat * mx2AsFloat + yAsFloat * my2AsFloat + zAsFloat * mz2AsFloat +z1AsFloat = xAsFloat * mx3AsFloat + yAsFloat * my3AsFloat + zAsFloat * mz3AsFloat END SUB -SUB gcp (x, y, z, x1, y1) +SUB Gcp (xAsFloat, yAsFloat, zAsFloat, x1AsFloat, y1AsFloat) -rx = x * mx1 + y * my1 + z * mz1 ' matrix transformation -ry = x * mx2 + y * my2 + z * mz2 -rz = x * mx3 + y * my3 + z * mz3 +rxAsFloat = xAsFloat * mx1AsFloat + yAsFloat * my1AsFloat + zAsFloat * mz1AsFloat ' Matrix transformation +ryAsFloat = xAsFloat * mx2AsFloat + yAsFloat * my2AsFloat + zAsFloat * mz2AsFloat +rzAsFloat = xAsFloat * mx3AsFloat + yAsFloat * my3AsFloat + zAsFloat * mz3AsFloat -rz = rz + 100 ' perspective calculation -x1 = rx / rz * 120 -y1 = ry / rz * 120 +rzAsFloat = rzAsFloat + 100 ' Perspective calculation +x1AsFloat = rxAsFloat / rzAsFloat * 120 +y1AsFloat = ryAsFloat / rzAsFloat * 120 END SUB -SUB gp (x, y, z, x1, y1) -rz = z + 100 ' perspective calculation -x1 = x / rz * 120 -y1 = y / rz * 120 +SUB Gp (xAsFloat, yAsFloat, zAsFloat, x1AsFloat, y1AsFloat) +rzAsFloat = zAsFloat + 100 ' Perspective calculation +x1AsFloat = xAsFloat / rzAsFloat * 120 +y1AsFloat = yAsFloat / rzAsFloat * 120 END SUB -SUB setan (alp, bet, gam) -mx1 = SIN(gam) * SIN(bet) * SIN(alp) + COS(gam) * COS(alp) -my1 = COS(bet) * SIN(alp) -mz1 = SIN(gam) * COS(alp) - COS(gam) * SIN(bet) * SIN(alp) +SUB Setan (alpAsFloat, betAsFloat, gamAsFloat) +mx1AsFloat = SIN(gamAsFloat) * SIN(betAsFloat) * SIN(alpAsFloat) + COS(gamAsFloat) * COS(alpAsFloat) +my1AsFloat = COS(betAsFloat) * SIN(alpAsFloat) +mz1AsFloat = SIN(gamAsFloat) * COS(alpAsFloat) - COS(gamAsFloat) * SIN(betAsFloat) * SIN(alpAsFloat) -mx2 = SIN(gam) * SIN(bet) * COS(alp) - COS(gam) * SIN(alp) -my2 = COS(bet) * COS(alp) -mz2 = -COS(gam) * SIN(bet) * COS(alp) - SIN(gam) * SIN(alp) +mx2AsFloat = SIN(gamAsFloat) * SIN(betAsFloat) * COS(alpAsFloat) - COS(gamAsFloat) * SIN(alpAsFloat) +my2AsFloat = COS(betAsFloat) * COS(alpAsFloat) +mz2AsFloat = -COS(gamAsFloat) * SIN(betAsFloat) * COS(alpAsFloat) - SIN(gamAsFloat) * SIN(alpAsFloat) -mx3 = -SIN(gam) * COS(bet) -my3 = SIN(bet) -mz3 = COS(gam) * COS(bet) +mx3AsFloat = -SIN(gamAsFloat) * COS(betAsFloat) +my3AsFloat = SIN(betAsFloat) +mz3AsFloat = COS(gamAsFloat) * COS(betAsFloat) END SUB -SUB star (x, y, z, an1, an2, an3) - -nan1 = an1 -nan2 = an2 -nan3 = an3 +SUB Star (xAsFloat, yAsFloat, zAsFloat, an1AsFloat, an2AsFloat, an3AsFloat) -setan nan1, nan2, nan3 -gp x, y, z, rx1, ry1 +nan1AsFloat = an1AsFloat +nan2AsFloat = an2AsFloat +nan3AsFloat = an3AsFloat -FOR n = 0 TO pi * 2 - .1 STEP pi / 5 - x1 = SIN(n) * 20 - y1 = COS(n) * 20 +Setan nan1AsFloat, nan2AsFloat, nan3AsFloat +Gp xAsFloat, yAsFloat, zAsFloat, rx1AsFloat, ry1AsFloat - gc x1, y1, 0, x2, y2, z2 - gp x2 + x, y2 + y, z2 + z, rx2, ry2 -CIRCLE (rx2, ry2), 1, 14 -LINE (rx2, ry2)-(rx1, ry1), 1 -NEXT n +FOR nAsInteger = 0 TO piAsDouble * 2 - .1 STEP piAsDouble / 5 + x1AsFloat = SIN(nAsInteger) * 20 + y1AsFloat = COS(nAsInteger) * 20 + Gc x1AsFloat, y1AsFloat, 0, x2AsFloat, y2AsFloat, z2AsFloat + Gp x2AsFloat + xAsFloat, y2AsFloat + yAsFloat, z2AsFloat + zAsFloat, rx2AsFloat, ry2AsFloat +CIRCLE (rx2AsFloat, ry2AsFloat), 1, 14 +LINE (rx2AsFloat, ry2AsFloat)-(rx1AsFloat, ry1AsFloat), 1 +NEXT nAsInteger END SUB -SUB start +SUB Start SCREEN 7, , , 1 WINDOW (-160, -100)-(160, 100) -pi = 3.141592 +piAsDouble = 3.141592 END SUB -SUB stic (x, y, z, an1, an2, an3) -nan1 = an1 -nan2 = an2 -nan3 = an3 + frm / 50 - -setan nan1, nan2, nan3 -gp x, y, z, rx1, ry1 - -DIM tmpx(0 TO 5) -DIM tmpy(0 TO 5) -DIM tmpz(0 TO 5) - -DIM tmprx(0 TO 5) -DIM tmpry(0 TO 5) -p = 0 - -FOR n = 0 TO pi * 2 - .5 STEP pi / 3 - x1 = SIN(n) * 100 - z1 = COS(n) * 100 - - gc x1, 100, z1, x2, y2, z2 - tmpx(p) = x2 + x - tmpy(p) = y2 + y - tmpz(p) = z2 + z - gp x2 + x, y2 + y, z2 + z, rx2, ry2 - tmprx(p) = rx2 - tmpry(p) = ry2 - LINE (rx1, ry1)-(rx2, ry2), 15 - - p = p + 1 -NEXT n +SUB Stic (xAsFloat, yAsFloat, zAsFloat, an1AsFloat, an2AsFloat, an3AsFloat) +nan1AsFloat = an1AsFloat +nan2AsFloat = an2AsFloat +nan3AsFloat = an3AsFloat + frmAsInteger / 50 + +Setan nan1AsFloat, nan2AsFloat, nan3AsFloat +Gp xAsFloat, yAsFloat, zAsFloat, rx1AsFloat, ry1AsFloat + +DIM tmpx(0 TO 5) AS FLOAT +DIM tmpy(0 TO 5) AS FLOAT +DIM tmpz(0 TO 5) AS FLOAT + +DIM tmprx(0 TO 5) AS FLOAT +DIM tmpry(0 TO 5) AS FLOAT +pAsInteger = 0 + +FOR nAsInteger = 0 TO piAsDouble * 2 - .5 STEP piAsDouble / 3 + x1AsFloat = SIN(nAsInteger) * 100 + z1AsFloat = COS(nAsInteger) * 100 + + Gc x1AsFloat, 100, z1AsFloat, x2AsFloat, y2AsFloat, z2AsFloat + tmpx(pAsInteger) = x2AsFloat + xAsFloat + tmpy(pAsInteger) = y2AsFloat + yAsFloat + tmpz(pAsInteger) = z2AsFloat + zAsFloat + Gp x2AsFloat + xAsFloat, y2AsFloat + yAsFloat, z2AsFloat + zAsFloat, rx2AsFloat, ry2AsFloat + tmprx(pAsInteger) = rx2AsFloat + tmpry(pAsInteger) = ry2AsFloat + LINE (rx1AsFloat, ry1AsFloat)-(rx2AsFloat, ry2AsFloat), 15 + + pAsInteger = pAsInteger + 1 +NEXT nAsInteger LINE (tmprx(0), tmpry(0))-(tmprx(2), tmpry(2)), 10 LINE (tmprx(2), tmpry(2))-(tmprx(4), tmpry(4)), 10 @@ -159,7 +161,6 @@ LINE (tmprx(1), tmpry(1))-(tmprx(3), tmpry(3)), 12 LINE (tmprx(3), tmpry(3))-(tmprx(5), tmpry(5)), 12 LINE (tmprx(5), tmpry(5))-(tmprx(1), tmpry(1)), 12 -star tmpx(0), tmpy(0), tmpz(0), nan1, nan2, nan3 +Star tmpx(0), tmpy(0), tmpz(0), nan1AsFloat, nan2AsFloat, nan3AsFloat END SUB -