--- title: "3-D Wire Frame Graphics" type: "article" slug: "3-d-wire-frame-graphics-4" url: "http://localhost/article/3-d-wire-frame-graphics-4/" markdown_url: "http://localhost/article/3-d-wire-frame-graphics-4.md" published_at: "2022-09-14T02:44:52+00:00" modified_at: "2026-06-21T23:23:27+00:00" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "The program listed below allows a person to define a 3-D object, draw it on the screen, and rotate it in three different planes. The heart of the program lies in how the object is represented. Two arrays hold the information for the object. An vertex array (list) holds all of the vertices. An edge…" category: - name: "Timelinez" slug: "timelinez" taxonomy: "category" url: "http://localhost/category/periodicals/timelinez/" post_tag: - name: "Full Text" slug: "fulltext" taxonomy: "post_tag" url: "http://localhost/tag/fulltext/" - name: "QL" slug: "ql" taxonomy: "post_tag" url: "http://localhost/tag/ql/" - name: "Type-in program" slug: "type-in-program" taxonomy: "post_tag" url: "http://localhost/tag/type-in-program/" model: - name: "Sinclair QL" slug: "sinclair-ql" taxonomy: "model" url: "http://localhost/model/sinclair-ql/" indiv: - name: "Tim Swenson" slug: "tim-swenson" taxonomy: "indiv" url: "http://localhost/indiv/tim-swenson/" publication_r: id: 21571 title: "Timelinez" type: "periodical" url: "http://localhost/periodical/timelinez/" authors: "Tim Swenson" authors_r: - name: "Tim Swenson" slug: "tim-swenson" taxonomy: "indiv" url: "http://localhost/indiv/tim-swenson/" volume: "5" issue: "8" issues_articles: - id: 39520 title: "TimeLinez v5 n8 Sep 1987" type: "issue" url: "http://localhost/issue/timelinez-v5-n8-sep-1987/" pages: "4-5" pubdate: "September 1987" related_articles: - id: 42385 title: "3-D Wire Frame Graphics" type: "article" url: "http://localhost/article/3-d-wire-frame-graphics/" - id: 42387 title: "3-D Wire Frame Graphics" type: "article" url: "http://localhost/article/3-d-wire-frame-graphics-2/" - id: 43899 title: "3-D Wire Frame Graphics" type: "article" url: "http://localhost/article/3-d-wire-frame-graphics-3/" archive_link: false --- # 3-D Wire Frame Graphics The program listed below allows a person to define a 3-D object, draw it on the screen, and rotate it in three different planes. The heart of the program lies in how the object is represented. Two arrays hold the information for the object. An vertex array (list) holds all of the vertices. An edge array (list) holds the two endpoints of the edges. The edgel array refers back to the vertex list for the actual points. It only holds the number of the vertex. Lines 100 to 1030 in the program holds the definition of a cube and some values for variables used by the program. Look at the diagrams and the the two lists to see how the cube is defined. More complex figures will take more information. The center of the cube is (0,0,90). This can be changed by the user. The variables XX, YY, and ZZ define the center that the user chooses. There are four procedures in the program. They are treated as keywords. To display the object the user can type in directly, or in a progran, DISPLAYS3D, ROTX, ROTY, and ROTZ rotate the object in radians held by the variable ROT. The program says that ROT is 20, its wrong. It should be in radians, like PI/10. Just to refresh your memory PI/2 is 90 degrees. When a rotation procedure is called the object is spun in the axis defined. Since the Z axis is pointing out of the screen, rotating the object will make it appear to spin like it is ona turntable and you are looking down on it. I hope this is clear. The variable D2 changes how large the object is on the screen. The larger the number the smaller the object. When you run the program as it is, nothing appears to happen. All it has done is to load the array with the data and set up the variables. Type ROTX, ROTY, and then DISPLAY3D. You will now see the cube at an angle. Have fun with the progran. If you have any questions feel free to contact me. Its hard to Summarize a lot of material ina short article. [![Image](http://localhost/wp-content/uploads/2022/09/CATS-v5-n7-Nov-1987_0007.jpg "CATS v5 n7 Nov 1987_0007")](http://localhost/wp-content/uploads/2022/09/CATS-v5-n7-Nov-1987_0007.jpg) ``` 100 DiM vertex (100, 3) 110 DIM edge (200,2) 190 RESTORE 200 READ xcenter, ycenter 210 READ d1, d2, rot 220 READ xx, yy, zz 230 READ vertexcount 240 FOR loop = 1 TO vertexcount 250 FOR loop2 = 1 TO 3 260 READ vertex (loop, loop2) 270 NEXT 1oop2 280 NEXT loop 290 READ edgecount 300 FOR loop = 1 TO edgecount 310 READ edge (loop, 1) 320 READ edge (loop, 2) 330 NEXT 1oop 1000 DATA 40,40, 1, 10,20 1010 DATA 9,0,0 1020 DATA 8,-1,-1,1,-1,1,1,1,-1,1,1,1,1,1,1, -1,1,-1,-1,-1,-1,-1,-1,1,-1 1030 DATA 12,1,2,2,4,4,3,3,1,7,8, 8,5,5,5,6,7,7,1,5,3,5,4,8,2 9000 DEFine PROCedure rotz 9010 FOR loop = 1 TO vertexcount 9020 x1 = vertex(lcop, 1) *COS (roti-vertex (loop, 2) *SIN (rot) 9030 71 = vertex(loop, 1)*SIN (rot. tvertex (loop, 2) *cos (rot) 9040 vertex (loop, 1) = x1 9050 vertex (loop, 2) = y1 9060 NEXT 100p 9090 END DEFine rotz 9100 DEFine PPOCedure roty 9110 FOR logp = 1 TO vertexcount* 9120 x1 = vertex (lcop, 1) *COS (rot)-vertex (loop, 3) *SIN (rot) 9130 z1 = vertex(loop, 1) *SIN (rot) +vertex (loop, 3) *COS (rot) 9140 vertex (loop, 1) = x1 9150 vertex (loop, 3) = z1 9160 NEXT 1oop 9190 END DEFine roty 9200 DEFine PROCedure rotx 9210 FOR 1oop = 1 TO vertexcount 9220 y1 = vertex (loop, 2) *COS (rot)-vertex (loop, 3) *SIN (rot) 9230 z1 = vertex (loop,2) *SIN (rot) vertex (loop, 3) *COS (rot) 9240 vertex (loop, 2) = y1 9250 vertex (1oop,3) = z1 9260 NEXT loop 9290 END DEFine rotx 9300 DEFine FuNction transx (x, d1, d2) 9305 LOCal xprime 9310 xprime = (x*d2)/d1 9315 RETurn xprime 9320 END DEFine transx 9330 DEFine FuNction transy (y, d1, d2) 9335 LOCal yprime 9340 yprime = (y*d2)/d1 9345 RETurn yprime 9350 END DEFine transy 9400 DEFine PROCedure display3d 9405 CLS 9410 FOR loop = 1 TO edgecount 9420 LET point1 = edge (loop, 1) 9430 LET point = edge (loop, 2) 9435 LET x1 = vertex(point1,1) - xX 9440 LET ×1 = transx (x1, d1, d2) 9445 LET ×2 = vertex (point2, 1) - xx 9450 LET x2 = transx (x2, d1, d2) 9455 LET y1 = verte(point1, 2) - УУ 9460 LET y1 = transy (y1, d1, d2) 9465 LET y2 = vertex (point2,2) - yy 9470 LET y2 = transy (y2, d1, d2) 9480 LINE x1+xcenter, y1+ycenter 10 x2+xcenter, y2+ycenter 9490 NEXT loop 9495 END DEFine display3d ```