Like e, π is an infinite non-recurring decimal; it starts off as 3.141592653589.... The word PI in NextBASIC is taken as standing for this number – try PRINT PI.

Trigonometry with SIN, COS, TAN, ASN, ACS and ATN

The trigonometrical functions measure what happens when a point moves round a circle. Here is a circle of radius 1 (1 what? It doesn't matter, as long as we keep to the same unit all the way through. There is nothing to stop you inventing a new unit of your own for every circle that you happen to be interested in) and a point moving round it. The point started at the 3 o'clock position, and then moved round in an anti-clockwise direction.

Fig. 6 – Basics of trigonometrical measurements Distance moved
around circle = a

Starting position

Radius = 1

Fig. 6 – Basics of trigonometrical measurements

We have also drawn in, two lines called axes through the centre of the circle. The one through 9 o'clock and 3 o'clock is called the x-axis, and the one through 6 o'clock and 12 o'clock is called the y-axis. To specify where the point is, you say how far it has moved round the circle from its 3 o'clock starting position: let us call this distance a. We know that the circumference of the circle is 2π (because its radius is 1 and its diameter is thus 2): so when it has moved a quarter of the way round the circle, a=π/2; when it has moved halfway round, a=π; and when it has moved the whole way round, a=2π.

Given the curved distance round the edge, a, two other distances you might like to know are how far the point is to the right of the y-axis, and how far it is above the x-axis. These are called, respectively, the cosine and sine of a. The functions COS and SIN on the computer will calculate these.

Note that if the point goes to the left of the y-axis, then the cosine becomes negative; and if the point goes below the x-axis, the sine becomes negative.

Another property is that once a has got up to 2π, the point is back where it started and the sine and cosine start taking the same values all over again:

SIN (a+2*PI) = SIN a
COS (a+2*PI) = COS a

The tangent of a is defined to be the sine divided by the cosine; the corresponding function on the computer is called TAN.

Sometimes we need to work these functions out in reverse, finding the value of a that has given sine, cosine or tangent. The functions to do this are called arcsine (ASN on the computer), arccosine (ACS) and arctangent (ATN).


ZX Spectrum Next User Manual, 3rd Edition (ISBN 978-1-5272-5496-1), written and illustrated by Phoebus R. Dokos. Copyright © 2020-2024 Phoebus Dokos / SpecNext Ltd. Licensed under CC BY-NC-SA 4.0. This is a transcription and can contain errors; check any doubt against the printed page.