★ CODING ★ LISTINGS ★ CAD FOR BEGINNERS PART 1 (AMSTRAD COMPUTER USER) ★ |
CAD for beginners part 1 (Amstrad Computer User) | Coding Listings |
David Robinson of Saxon Computing shows how the CPC464 can produce 3D drawings from simple 2D sections. Around the end of May I was asked if I'd present a graphics program which I'd evolved during my acquaintance with the CPC464 in the launch issue of AMSTRAD USER. The ideas began to flow, and then grew into a regular column for the magazine on the subject of computer graphics, and so now I have a splendid excuse, at least once a month, to get away from writing business software! Some graphics applications require so much computing that even the Locomotive BASIC inside your 464 (just about the fastest standard 8 bit BASIC around) can seem a bit slow. Where a program could do with some extra speed I will list the program both in BASIC and PASCAL for those of you with the HiSoft PASCAL 4T compiler. Every program is accompanied by a full commentary and a list of suggested improvements and extensions for you to try out yourself. Your CPC464 has some very useful graphics features not found on any other micro under £500. These allow us to use techniques more associated with mainframe graphics computers than most micros. Three other important features are:- 1) a palette of 27 colours to choose from. 2) switchable screen resolution -but using a common coordinate 3) VERY IMPORTANT - the colour resolution is the same as the pixel resolution. A 3D wire frame plotter This program of 3D drawings translates a two dimensional cross section into a full 3D shape. To get an idea of how it works, look at Figure la which shows the right half of the cross section of a wine glass. The left half is, of course, a simple mirror image, so the program does not require us to draw both halves. Figure lb shows the 3D projection drawn by the computer from the cross section. Significant line numbers are as follows:
(FACES) in the final picture. Rotates the 2D cross section data in 3D space in steps of 360 degrees/FACES. A point to note is the use of integer variables wherever possible to improve the speed of computation. You could try to make some improvements to the program along the following lines - 1) Draw a line along the centre of the input screen to mark the centre line for the cross section. 2) The ‘dot cursor' will erase any previously drawn lines whilst on its travels about the screen. See if you can write a routine to prevent this. Save the program on tape as we shall be using it again in later issues.
|