```
1 REM Rotation
10 MODE 4: VDU 29,640;512;: XS=4: YS=4
20 A=640: B=A*A: C=512
30 FOR X=0 TO A STEP XS: S=X*X: P=SQR(B-S)
50 FOR I= -P TO P STEP 6*YS
70 R=SQR(S+I*I)/A
80 Q=(R-1)*SIN(24*R)
90 Y=I/3+Q*C
95 IF I= -P THEN M=Y: GOTO 110
l00 IF Y>M M=Y: GOTO 130
105 IF Y>=N: GOTO 140
110 N=Y
130 PLOT69,-X,Y: PLOT69,X,Y
140 NEXT I: NEXT X
150 END
```

From ‘Practical Programs for the BBC Micro’ by David Johnson-Davies

Created with the Fiskur BBC Micro Android app.

For completeness and to explain the code the text from the book is copied below:

*This program plots a three-dimensional view of a surface using high-resolution graphics, To give a solid appearance to the surface, lines which lie behind the surface are not plotted; in other words, the program incorporates ‘hidden-line removal’. The function for evaluation is given in line 80 of the two versions of the program, and can be any surface of revolution, in which the height, Q is simply a function of the radius from the centre, R.*

*As an example, the equation:*

`Q=(R-1)*SIN(24*R)`

*where the SIN function gives a rippled effect, and the (R-1) factor causes the ripples to die away towards the edge.*

*BBC Computer Version*

*The BBC Computer version uses the medium-resolution graphics mode, with a resolution of 320×256. The origin is set to 640,512, the centre of the virtual graphics screen.*

`1 REM ... Rotation ...`

*Set up graphics resolution.*

```
10 MODE 4: VDU 29,640;512;: XS=4: YS=4
20 A=640: B=A*A: C=512
```

*Plot for every X coordinate.*

```
30 FOR X=O TO A STEP XS: S=X*X: P=SQR(B-S)
50 FOR I=-P TO P STEP 6*YS
```

*Calculate R = distance from centre and solve function; Q = height. Give Y coordinate, with correct perspective.*

```
70 R=SQR(S+I*I)/A
80 Q=(R-1)*SIN(24*R)
90 Y=I/3+Q*C
```

*For first point, set maximum and minimum.*

```
95 IF I=-P THEN M=Y: GOTO 110
l00 IF Y>M M=Y: GOTO 130
105 IP Y>=N GOTO 140
110 N=Y
```

*Plot points symmetrically each side of centre.*

```
130 PLOT69,-X,Y: PLOT69,X,Y
140 NEXT I: NEXT X
150 END
```

*Variables:*

*A – X resolution*

- B – Square of X resolution*
- C – Y resolution*
- I – Distance along X axis*
- M – Highest point plotted*
- N – lowest point plotted*
- Q – height of function*
- R – radius from centre*
- X – X coordinate from centre*
- Y – Y coordinate*
- XS,YS – Virtual points per screen point*

*Further Suggestions*

*Another function can be obtained by altering lines 80 and 90 of the programs to:*

```
80 Q=COS(R*5)*EXP(-R)
90 Y=I/3-Q*C-5
```