# 5.1 Phy1020: brief trigonometry tutorial  (Page 19/20)

 Page 19 / 20

The code in Listing 9 begins by defining a function named getAngle that accepts the signed values of the adjacent side and the opposite side of the righttriangle and returns the angle that the hypotenuse makes with the positive horizontal axis.

Then the code in Listing 9 tests the result for four different triangles situated in each of the four quadrants.

Figure 18 shows the output produced by this script.

Figure 18 . Output from the code in Listing 9.
```Start Script adj = 3.00 opp = 4.00 unitsangle = 53.13 units adj = -3.00 opp = 4.00 unitsangle = 126.87 units adj = -3.00 opp = -4.00 unitsangle = 233.13 units adj = 3.00 opp = -4.00 unitsangle = -53.13 units```

This is an issue that will become important when we reach the module that deals with vectors in all four quadrants.

Structure of the script

The script shown in Listing 9 begins by defining a function named getAngle . The purpose of this function is to return an angle in degrees in the correct quadrant based on the lengths of the adjacent and opposite sidesof an enclosing right triangle. As mentioned above, the returned angle is the angle that the hypotenuse makes with the positive horizontal axis.

An indeterminate result

The getAngle function calls the Math.atan method to compute the angle whose tangent is the ratio of the opposite side to the adjacent side of a righttriangle.

If the lengths of both the opposite and adjacent sides are zero, the ratio opposite/adjacent is indeterminate and the value of the angle cannot be computed. In fact there is noangle corresponding to the ratio 0/0. However, the function must either return the value of an angle, or must return some sort of flag indicating thatcomputation of the angle is not possible.

In this case, the function simply returns the value zero for the angle.

Avoiding division by zero

If the length of adjacent side is zero and the length of opposite side is not zero, the ratio opposite/adjacent is infinite. Therefore, the value of the angle cannot becomputed. However, in this case, the angle is known to be 90 degrees (for opposite greater than zero) or 270 degrees (-90 degrees, for opposite less thanzero). The getAngle function traps both of those cases and returns the correct angle in each case.

The Math.atan method receives one parameter and it is either a positive or negative value. If the value is positive, the method returns an angle between 0and 90 degrees. If the value is negative, the method returns an angle between 0 and -90 degrees. Thus, the angles returned by the Math.atan method always lie inthe first or fourth quadrants.

(Actually, as I mentioned earlier, +90 degrees and -90 degrees are not possible because the tangent of +90 degrees or -90 degrees is an infinitelylarge positive or negative value. However, the method can handle angles that are very close to +90 or -90 degrees.)

If the opposite/adjacent ratio is negative, this doesn't necessarily mean that the angle lies in the fourth quadrant. That negative ratio could resultfrom a positive value for opposite and a negative value for adjacent. In that case, the angle would lie in the second quadrant between 90 degrees and 180degrees.

what is the stm
How we are making nano material?
what is a peer
What is meant by 'nano scale'?
What is STMs full form?
LITNING
scanning tunneling microscope
Sahil
how nano science is used for hydrophobicity
Santosh
Do u think that Graphene and Fullrene fiber can be used to make Air Plane body structure the lightest and strongest. Rafiq
Rafiq
what is differents between GO and RGO?
Mahi
what is Nano technology ?
write examples of Nano molecule?
Bob
The nanotechnology is as new science, to scale nanometric
brayan
nanotechnology is the study, desing, synthesis, manipulation and application of materials and functional systems through control of matter at nanoscale
Damian
Is there any normative that regulates the use of silver nanoparticles?
what king of growth are you checking .?
Renato
What fields keep nano created devices from performing or assimulating ? Magnetic fields ? Are do they assimilate ?
why we need to study biomolecules, molecular biology in nanotechnology?
?
Kyle
yes I'm doing my masters in nanotechnology, we are being studying all these domains as well..
why?
what school?
Kyle
biomolecules are e building blocks of every organics and inorganic materials.
Joe
anyone know any internet site where one can find nanotechnology papers?
research.net
kanaga
sciencedirect big data base
Ernesto
Introduction about quantum dots in nanotechnology
what does nano mean?
nano basically means 10^(-9). nanometer is a unit to measure length.
Bharti
do you think it's worthwhile in the long term to study the effects and possibilities of nanotechnology on viral treatment?
absolutely yes
Daniel
how to know photocatalytic properties of tio2 nanoparticles...what to do now
it is a goid question and i want to know the answer as well
Maciej
Abigail
for teaching engĺish at school how nano technology help us
Anassong
How can I make nanorobot?
Lily
Do somebody tell me a best nano engineering book for beginners?
there is no specific books for beginners but there is book called principle of nanotechnology
NANO
how can I make nanorobot?
Lily
what is fullerene does it is used to make bukky balls
are you nano engineer ?
s.
fullerene is a bucky ball aka Carbon 60 molecule. It was name by the architect Fuller. He design the geodesic dome. it resembles a soccer ball.
Tarell
what is the actual application of fullerenes nowadays?
Damian
That is a great question Damian. best way to answer that question is to Google it. there are hundreds of applications for buck minister fullerenes, from medical to aerospace. you can also find plenty of research papers that will give you great detail on the potential applications of fullerenes.
Tarell
Berger describes sociologists as concerned with
Got questions? Join the online conversation and get instant answers!     By By  By  By