Figure 1.
You couldn't use the same technique to measure the height of a mountain peak which is miles away and covered in clouds. The clouds would get in your way, and you couldn't measure the horizontal distance. An instrument such as a tellinometer would help. This uses radar to locate the top of the mountain. It also measures the angle and distance between you and the top. A scale drawing would provide a way of calculating the height of the mountain. See Figure 2.
As a further example suppose we wanted to find the width of a large pond or lake; see Figure 3.
Figure 2.
Figure 3.
A scale drawing could be produced from the measurements made, and the required distance estimated.
Here is a related example. A navigator is at a certain position A. He is 150km due west of city B and 188 km from city C. The angle between the two cities is 23 degrees measured from his position. How far apart are the two cities? Again, a scale drawing could provide the answer.
Although scale drawings will provide answers to the problems mentioned above, they are rough and ready. And they cannot always be practicably or accurately reproduced. An alternative approach is to do the necessary calculations by trigonometry using your computer.
TAN(X) | = | opposite | |||
adjacent | |||||
SIN(X) | = | opposite | |||
hypotenuse | |||||
COS(X) | = | adjacent | |||
hypotenuse |
SIN(0) = 0 | COS(0) = 1 | TAN(0) = 0 |
SIN(30) = 0.5 | COS(30) = SQR(3)/2 | TAN(30) = 1/SQR(3) |
SIN(45) = 1/SQR(2) | COS(45) = 1/SQR(2) | TAN(45) = 1 |
SIN(60) = SQR(3)/2 | COS(60) = 1/2 | TAN(60) = SQR(3) |
SIN(90) = 1 | COS(90) = 0 |
If you know the angle X and one of the three lengths of a right-angled triangle then you can find the other two lengths. For example, if you know the angle X and the length of the adjacent side then the other two lengths are given by the following formulae.
opposite = TAN(X) * adjacent
hypotenuse = adjacent / COS(X)
Another way of describing the trigonometric function is by using a circle of radius 1 unit. Measure out the angle required as shown in Figure 5. The values of the various trigonometric functions are indicated.
Figure 5.
Mathematically, distances are measured horizontally from left to right and vertically upwards. This explains why, for instance, in Figure 6, COS(X) has a negative value.
Figure 6.
You can obtain SIN, COS and TAN of an angle X by typing
PRINT SIN(X) etc.,
substituting the appropriate value of X. The only possible problem is that the BBC and Electron micros, in common with most microcomputers, expect the angles in radians, not degrees. Fortunately degrees can be turned into radians and vice versa very easily.
First of all, what is a radian? Draw a circle of radius 1 unit. Measure along the circumference of your circle a distance which is equal to the radius of the circle. The angle subtended by this arc is 1 radian. 1 radian is approximately 57 degrees. See Figure 7.
The number PI is both remarkable and famous. It is defined as the ratio of the circumference of a circle to the diameter. The (approximate) value of PI is stored in your micro. Simply type
PRINT PI
to reveal the value stored. In a circle of radius 1 unit the diameter is 2 units. Thus the circumference of the circle is 2*PI and so there are 2*PI radians in a complete circle. Since there are 360 degrees in a complete circle we see that
360 degrees = 2*PI radians, and
180 degrees = PI radians
Figure 7.
We can convert degrees to radians and vice versa quite easily with the following formulae:
X degrees = X*PI/180 radians
Y radians = Y*180/PI degrees
More easily, we can use two of the functions available on your computer, RAD and DEG:
X degrees is RAD(X) radians
Y radians is DEG(Y) degrees
The following program can be used to find lengths of right angled triangles. You need to input an angle and one distance. The program calculates the other two lengths.
Listing 2.1
LIST
10 REM Program for right-angled trian gles 20 CLS:PRINT ' TAB(9);"Right-angled t riangles"' 30 PRINT "This program enables you to find the" 40 PRINT "sides of a right angled tri angle" 50 PRINT "provided you know one side and angle."' 60 PRINT " * **" 70 PRINT " * * * *" 80 PRINT " Hypotenuse * * Oppos ite * *" 90 PRINT " * * *Angle * *********" 95 PRINT " Adjacent"' 100 REM Input details 105 @%=&02040A 110 REPEAT 120 INPUT "Angle, in degrees. ";X 130 IF X<=0 OR X>=90 THEN PRINT "Error - not a triangle."' 140 UNTIL X>0 AND X<90 150 PRINT '"Which side do you know? 1 (Opposite)" 160 PRINT "2 (Adjacent) or 3 (Hypotenu se)." 170 REPEAT 180 INPUT "Type 1, 2 or 3 ";T 190 UNTIL T>0 AND T<4 AND T=INT(T) 200 PRINT '"Type in the length of this side." 210 REPEAT 220 INPUT "Length ";L 230 IF L<=0 THEN PRINT "Funny - try ag ain."' 240 UNTIL L>0 250 X=RAD(X) 260 ON T GOSUB 300,350,400 270 PRINT CHR$(7) '"That's it - anothe r go? Y or N "; 280 REPEAT:G$=GET$:UNTIL G$="Y" or G$= "N" 290 IF G$="Y" THEN RUN ELSE CLS:PRINT '"Bye for now.":END 300 REM Opposite side known 310 PRINT '"Adjacent side:" L/TAN(X) 320 PRINT " Hypotenuse:" L/SIN(X) 330 RETURN 350 REM Adjacent side known 360 PRINT '"Opposite side:" TAN(X)*L 370 PRINT " Hypotenuse:" L/COS(X) 380 RETURN 400 REM Hypotenuse known 410 PRINT '"Opposite side:" SIN(X)*L 420 PRINT "Adjacent side:" L*COS(X) 430 RETURN
RUN
Right-angled triangles This program enables you to find the sides of a right angled triangle provided you know one side and angle. * ** * * * * Hypotenuse * * Opposite * * * * *Angle * ********* Adjacent Angle, in degrees. ?30 Which side do you know? 1 (Opposite) 2 (Adjacent) or 3 (Hypotenuse). Type 1, 2 or 3 ?1 Type in the length of this side. Length ?0.5 Adjacent side: 0.8660 Hypotenuse: 1.0000 That's it - another go? Y or N
Figure 8.
If we know the values of A and B then we can find the value of the angle X. We know that TAN(X) = B/A, thus X = ATN(B/A). You can put the appropriate values in this expression and get your computer to print out the answer. Of course, the answer would be in radians. To get an answer in degrees you need to multiply the result by 180/PI.
The trigonometric functions SIN and COS also have inverse functions denoted by ASN (arc sine) and ACS (arc cosine) respectively. ASN(N) is that angle whose sine is N; similarly ACS(N) is that angle whose cosine is N. Both of these functions are available on your micro, but it is also interesting to see how easily they can be obtained from the ATN function.
To see how we obtain ASN from ATN look at the right-angled triangle with a hypotenuse of length 1 unit in Figure 9.
Figure 9.
Now suppose that we know the value of B, and we want to find the angle X. We know that SIN(X) = B so that X = ASN(B). If we knew the value of A then we could use ATN since X = ATN(B/A) also. To find A we use Pythagoras' theorem.
Recall the theorem of Pythagoras. In words, it states that the square of the hypotenuse of a right-angled triangle is equal to the sum of the squares of the other two sides. In symbols we have
C2 = A2 + B2
where C is the length of the hypotenuse. Since our hypotenuse is of length 1 we have:
1 = A*A + B*B
or
A*A = 1 - B*B
and so
A = SQR(1 - B*B)
Since X = ATN(B/A) we obtain
X = ATN(B/SQR(1 - B*B))
also, ASN(B) = X, and so we obtain
ASN(B) = ATN(B/SQR(1 - B*B))
In a similar way we could produce a formula for ACS(A), such as:
ACS(A) = PI/2 - ATN(A/SQR(1 - A*A))
You should notice that ACS(A) = PI/2 - ASN(A).
Figure 10.
The following formulae relate the various sides and angles.
The law of cosines
SZ*SZ = SX*SX + SY*SY - 2*SX*SY*COS(Z)
SY*SY = SX*SX + SZ*SZ - 2*SX*SZ*COS(Y)
SX*SX = SY*SY + SZ*SZ - 2*SY*SZ*COS(X)
The law of sines:
SIN(X)/SX = SIN(Y)/SY = SIN(Z)/SZ
Notice that if Z is a right angle (that is 90 degrees) then COS(Z) = 0 and so the first formula becomes:
SZ*SZ = SX*SX + SY*SY
which is just Pythagoras' theorem.
The next program will find the remaining angles and sides provided you know one of the following:
Side Side Side : You know all three sides and are looking for the measurements of the three angles.
Side Side Angle : You know two sides and an angle which is not between them (a non-inclusive angle) and you are looking for the other side and angles.
Side Angle Side : You know two sides and the angle between them (the inclusive angle) and you are looking for the other side and angles.
Side Angle Angle : You know two angles and a side which is not between them (a non-inclusive angle) and you are looking for the other two sides and the third angle.
Angle Side Angle : You know two angles and the side between them (the inclusive side) and you are looking for the other two sides and the third angle.
Notice that in the second case (Side Side Angle) two different triangles are (usually) possible depending on whether the angle opposite side 3 is greater or less than 90 degrees. See Figure 11 which illustrates this point.
Listing 2.2
LIST
10 REM Triangles 20 MODE 1:COLOUR 3:PRINT ' TAB(15);"T riangles"' 30 PRINT "This program will find the remaining" 40 PRINT "sides and angles of a trian gle."' 50 PRINT "Which information do you ha ve?"' 60 PRINT "1> SSS : all 3 sides"' 70 PRINT "2> SSA : 2 sides and non-in clusive angle" 80 PRINT "3> SAS : 2 sides and inclus ive angle"' 90 PRINT "4> SAA : 2 angles and non-i nclusive side" 100 PRINT "5> ASA : 2 angles and inclu sive side"' 110 REM Make selection 120 REPEAT 130 INPUT "Type in number ";N 140 IF N<1 OR N>5 OR N<>INT(N) PRINT "Try 1, 2, 3, 4 or 5." 150 UNTIL N>0 AND N<6 AND N=INT(N) 160 PRINT:ON N GOSUB 210,410,610,810,9 10 170 COLOUR 3:PRINT ' CHR$(7) TAB(10);" Another go? Y or N "; 180 REPEAT:G$=GET$:UNTIL G$="Y" OR G$= "N" 190 IF G$="Y" THEN RUN ELSE CLS:PRINT '"Bye for now.":END 200 REM All 3 sides 210 PRINT "*** All 3 sides known"' 220 M=1:SX=FNside(S) 230 M=2:SY=FNside(S) 240 M=3:SZ=FNside(S) 250 A=FNlaw(SY,SZ,SX) 260 IF ABS(A)>=1 THEN PRINT "Not a tri angle!":RETURN 270 PRINT "Angle opposite side 1 is "; DEG(ACS(A)) 280 A=FNlaw(SX,SZ,SY) 290 PRINT '"Angle opposite side 2 is " ;DEG(ACS(A)) 300 A=FNlaw(SX,SY,SZ) 310 PRINT '"Angle opposite side 3 is " ;DEG(ACS(A)) 320 RETURN 400 REM 2 sides and a non-inclusive an gle 410 PRINT "** 2 sides and a non-inclus ive angle ** " 420 PRINT "Type in the side for which the opposite angle is known"' 430 M=1:SX=FNside(S):AX=FNangle(A) 440 M=2:SY=FNside(S) 450 A=SIN(AX)*SY/SX:IF ABS(A)>1 OR A=0 THEN PRINT "Not a triangle!":RETURN 460 PRINT "Is angle opposite side 2 gr eater (>) or less (<) then 90 degrees?" 470 REPEAT 480 INPUT "Type > or < ";A$ 490 UNTIL A$=">" OR A$="<" 500 AY=DEG(ASN(A)):IF A$=">" AND AY<90 THEN AY=90+AY 510 PRINT '"Angle opposite side 2 is " ;AY 520 AZ=PI-AX-AY*PI/180 530 PRINT '"Length of side 3 is ";SX*S IN(AZ)/SIN(AX) 540 PRINT '"Angle opposite side 3 is " ;DEG(AZ) 550 RETURN 600 REM 2 sides and the inclusive angl e 610 PRINT "*** 2 sides and the inclusi ve angle *** " 620 M=1:SX=FNside(S) 630 M=2:SY=FNside(S) 640 M=3:AZ=FNangle(A) 650 SZ=SQR(SX*SX+SY*SY-2*SX*SY*COS(AZ) ) 660 IF SZ=0 THEN PRINT "Not a triangle !":RETURN 670 PRINT "Length of side 3 is ";SZ 680 A=FNlaw(SY,SZ,SX) 690 PRINT '"Angle opposite side 1 is " ;DEG(ACS(A)) 700 A=FNlaw(SY,SZ,SX) 710 PRINT '"Angle opposite side 2 is " ;DEG(ACS(A)) 720 RETURN 800 REM 2 angles and a non-inclusive s ide 810 PRINT "** 2 angles and a non-inclu sive side ** " 820 PRINT "Type in the angle for which the oppositeside is known first."' 830 M=1:AX=FNangle(A):SX=FNside(S) 840 M=2:AY=FNangle(A) 850 A=PI-AX-AY:IF A<=0 THEN PRINT "Not a triangle!":RETURN 860 PRINT "Length of side 2 is ";SX*SI N(AY)/SIN(AX) 870 PRINT '"Angle of opposite side 3 i s ";DEG(A) 880 PRINT '"Length of side 3 is ";SX*S IN(A)/SIN(AX) 890 RETURN 900 REM 2 angles and an inclusive side 910 PRINT "*** 2 angles and an inclusi ve side *** " 920 M=1:AX=FNangle(A) 930 M=2:AY=FNangle(A) 940 M=3:SZ=FNside(S) 950 A=PI-AX-AY:IF A<=0 THEN PRINT "Not a triangle!":RETURN 960 PRINT "Angle opposite side 3 is "; DEG(A) 970 PRINT '"Length of side 1 is ";SZ*S IN(AX)/SIN(A) 980 PRINT '"Length of side 2 is ";SZ*S IN(AY)/SIN(A) 990 RETURN 1000 REM get a side 1010 DEF FNside(S) 1020 @%=10:COLOUR 2 1030 REPEAT 1040 S=0:PRINT "Type length of side " ;M;" : ";:INPUT S:PRINT 1050 IF S<=0 THEN PRINT "Not a triang le!" 1060 UNTIL S>0 1070 @%=&02020A:COLOUR 1 1080 =S 1100 REM get an angle 1110 DEF FNangle(A) 1120 @%=10:COLOUR 2 1130 REPEAT 1140 A=0:PRINT "Type angle opposite s ide ";M;" : ";:INPUT A:PRINT 1150 IF A<=0.001 OR A>=180 THEN PRINT "Not a triangle!" 1160 UNTIL A>0.001 AND A<180 1170 @%=&02020A:COLOUR 2 1180 A=RAD(A) 1190 =A 1200 REM Define formula for cosine form ula 1210 DEF FNlaw(A,B,C)=(A*A+B*B-C*C)/(2* A*B)
RUN
Triangles This program will find the remaining sides and angles of a triangle. Which information do you have? 1> SSS : all 3 sides 2> SSA : 2 sides and non-inclusive angle 3> SAS : 2 sides and inclusive angle 4> SAA : 2 angles and non-inclusive side 5> ASA : 2 angles and inclusive side Type in number ?4 ** 2 angles and a non-inclusive side ** Type in the angle for which the opposite side is known first. Type angle opposite side 1 : ?35 Type length of side 1 : ?2.5 Type angle opposite side 2 : ?55 Length of side 2 is 3.57 Angle of opposite side 3 is 90.00 Length of side 3 is 4.36 Another go? Y or N
Figure 11.
refractive index = | SIN(angle of incidence) | |
SIN(angle of refraction) |
Figure 12.
The program allows you to determine the angle of refraction, assuming that you know the angle of incidence and the refractive index.
Listing 2.3
LIST
10 REM Refraction program 20 MODE 1:COLOUR 3:PRINT ' TAB(15);"R efraction"' 30 PRINT "This program calculates the angle of" 40 PRINT "refraction when a ray of li ght hits" 50 PRINT "another medium."' 60 @%=10 100 REM Input details 110 COLOUR 2:PRINT "Type in angle of i ncidence, in degrees." 120 REPEAT 130 INPUT "Angle: ";X 140 IF X<=0 OR X>=90 THEN COLOUR 3:PR INT "Error - nonsense"':COLOUR 2 150 UNTIL X>0 AND X<90 160 PRINT '"What is the refractive ind ex of the medium?" 170 REPEAT 180 INPUT "Refractive index: ";R 190 IF R<=0 THEN COLOUR 3:PRINT "Funn y - try again"':COLOUR 2 200 UNTIL R>0 210 X=RAD(X) 220 REM Calculate 230 Y=SIN(X)/R:COLOUR 1 240 PRINT '"Angle of refraction: ";INT (DEG(ASN(Y))*100)/100;" degrees." 250 PRINT '"Percentage of angle of inc idence: ";INT(ATN(Y)*100/X);"%" 260 COLOUR 3:PRINT ' CHR$(7) "That's i t - another go? Y or N "; 270 REPEAT:G$=GET$:UNTIL G$="Y" OR G$= "N" 280 IF G$="Y" THEN RUN 290 CLS:PRINT '"Bye for now.":END
RUN
Refraction This program calculates the angle of refraction when a ray of light hits another medium. Type in angle of incidence, in degrees. Angle: ?25 What is the refractive index of the medium? Refractive index: ?1.333 Angle of refraction: 18.48 degrees. Percentage of angle of incidence: 70% That's it - another go? Y or N
SIN(critical angle) = | 1 |
refractive index |