04.03.2013 Views

spectrum graphics - OpenLibra

spectrum graphics - OpenLibra

spectrum graphics - OpenLibra

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

10 REM CUBOID DRAWING<br />

20 LET OX-=30: LET OY=40<br />

30 LET A-30: LET B=40: LET C=1<br />

5: LET D-20<br />

40 PLOT OX,OY<br />

50 DRAW 0,A: DRAW B,0: DRAW 0,<br />

-A: DRAW -B,0<br />

60 DRAW C,D: DRAW B,0: DRAW -C<br />

70 PLOT OX+0,OY+A! DRAW C,D: D<br />

RAW B,9I DRAW -C,-D<br />

80 PLOT OX+C,OY+D! DRAW 0,A! D<br />

RAW B,0: DRAW 0,-A<br />

90 LET A-A+L! LET B*B+L: LET C<br />

«=c + l: LET D=D+1<br />

Figure 3<br />

100 STOP<br />

make a flat two-dimensional<br />

representation appear threedimensional<br />

and provide the<br />

basis for animating such an object.<br />

The diagram in figure 5<br />

shows how a single point viewed<br />

from the origin of the coordinateslx.y<br />

and z) can be<br />

represented on the picture plane<br />

at a set distance from the view<br />

point. The picture plane of<br />

course is our television screen<br />

and the x and y coordinates of<br />

the point on it with respect to<br />

the bottom left hand coner are<br />

calculated as x times (distance<br />

of picture plane to viewpoint<br />

axis divided by z). This is called<br />

transforming and is good for any<br />

object where the viewpoint and<br />

the origin of the coordinate<br />

system are the same place.<br />

Some degree of animation is<br />

now possible once the threedimensions<br />

are transformed into<br />

two on the picture plane. The<br />

x ,y coordinates can be<br />

transformed around the screen<br />

enlarged, reduced, moved or<br />

rotated and the perspective<br />

altered by shifting the picture<br />

plane. Rotation presents an interesting<br />

problem because one<br />

has to resort to sines and<br />

cosines to solve the shifting of x<br />

and y coordinates about the centre<br />

of rotation. Taking an anticlockwise<br />

rotation through a<br />

specifiedangle, A, then the new<br />

coordinates of the point x,y will<br />

be calculated as x cosine A-y<br />

sine A for the x coordinate, and x<br />

sine A + y sine A for the y coordinate.<br />

This idea is incorporated<br />

Figure 5<br />

ZX CRAPHICS<br />

Figure 4<br />

VIEWED POINT AT x,y,z<br />

x = 0<br />

y = 0<br />

(ON SCREEN)<br />

x{d/z|<br />

y(d/z)<br />

10 REM DOUBLE SIZE CHARACTERS<br />

20 LET XC-L: LET YC-1<br />

30 PRINT AT 10,10("A"<br />

40 DIM A (8 , 8)<br />

30 REM SCAN CHARACTER<br />

60 FOR X»0 TO 7<br />

70 FOR Y=0 TO 7<br />

80 IF POINT (X+80,Y+88)=1 THEN<br />

LET A(X+L,Y+L)=1<br />

90 NEXT Y<br />

100 NEXT X<br />

110 REM REPRODUCE ENLARGED<br />

120 FOR<br />

130 FOR<br />

140 LET<br />

HEN LET<br />

X=1 TO 16<br />

Y=1 TO 16<br />

YC=INT (Y/2): IF YC=0 T<br />

YC = 1<br />

130 IF A < XC,YC)<br />

96,Y+84<br />

160 LET XC-INT (X/2)<br />

HEN LET XC-1<br />

170 NEXT Y<br />

180 NEXT X<br />

PICTURE PLANE (SCREEN)<br />

PARALLEL TO x,y PLANE<br />

TRANSFORMED<br />

POINT AT x,y<br />

ORIGIN AND VIEWPOINT<br />

(0.0,0)<br />

1 THEN PLOT X+<br />

IF XC=0 T<br />

DISTANCE OF PICTURE<br />

PLANE FROM ORIGIN<br />

34 ZX COMPUTING DECEMBER/JANUARY 1985

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!