edited March 9 in BASIC
3-D drawing Popular Computer Weekly 25-11-82 page 15

on Spectrum
This program, which manipulates a shape
defined by the operator in three dimen-
sions, is developed round a simple circle
drawing routine. If the cicle is stepped
round in steps of 2PI/N, a polygon of N

sides will result. If the vertical axis is
reduced then the shape will appear to tilt. If
another circle is employed then a solid
object can be represented; a prism for
 The vertical axis is reduced by dividing
by Sin (tilt), and the distance between the
centres of the two ends is calculated by

Cos (tilt) perpendicular separation.
 The controls are the standard cursor
controls and the shape can be a prism or a
cone, with any height, width, ratio or
number of sides. A side can also be
marked, to facilitate in understanding the
complex pattern of lines. FNa converts
relative drawing to absolute.

(edit: 23677 = X COORD, 23678 = Y COORD)

   1 LET s=1: BORDER 7: PAPER 7: INK 0: CLS
   2 PRINT "How many sides?";: INPUT sides: PRINT sides: LET sides=sides/2
   3 LET c=1: PRINT "Do you want a cone?": INPUT a$: IF a$="y" THEN LET c=0
   4 IF c=1 THEN PRINT "Do you want a side marked?": INPUT s$: IF s$="y" THEN LET s=0
   5 DEF FN a(g)=PEEK (23677+g)
   6 PRINT "How tall do you want it?": INPUT t
   7 PRINT "How wide do you want it?": INPUT size
  10 GO TO 200
  20 CLS: FOR a=rot TO rot+2*PI STEP step
  30 PLOT 128+size*c*SIN a,85+x+c*y*COS a
  35 LET a=a+step
  40 DRAW (128+size*SIN a*c)-FN a(0),(85+x+y*COS a*c)-FN a(1)
  50 DRAW (128+size*SIN a)-FN a(0),(85-x+y*COS a)-FN a(1)
  55 LET a=a-step
  60 DRAW (128+size*SIN a)-FN a(0),(85-x+y*COS a)-FN a(1)
  65 NEXT a
  66 IF c=0 OR s=1 THEN RETURN
  70 PLOT 128+size*SIN rot,85+x+y*COS rot
  80 DRAW (128+size*SIN (rot+step))-FN a(0),(85-x+y*COS (rot+step))-FN a(1)
  90 PLOT 128+size*SIN (rot+step),85+x+y*COS (rot+step)
 100 DRAW (128+size*SIN (rot))-FN a(0),(85-x+y*COS (rot))-FN a(1)
 200 LET tilt=10:LET rot=5: LET step=PI/sides
 210 LET x=t*COS tilt
 220 LET y=size*SIN tilt
 230 GO SUB 20
 235 IF INKEY$="" THEN GO TO 235
 240 LET tilt=tilt+(INKEY$="6")/5-(INKEY$="7")/5
 242 LET rot=rot+(INKEY$="5")/4-(INKEY$="8")/4
 250 GO TO 210

Post edited by Crisis on
my old website has changed to so just click it and select a file


Sign In or Register to comment.