Home | Gaming | Programming | Play Online | Contact | Keyword Query
Games++ Games & Game Programming

Physics For<br>Game Developers

Physics For
Game Developers

Mathematics for<br>3D Game Programming<br>& Computer Graphics

Mathematics for
3D Game Programming
& Computer Graphics

Lionel's Trigonometry Tutorial for Programmers

Part 2: Basic Trigonometric Ratios

1. INTRODUCTION

In this tutorial, we will take a look at the three basic trigonometric
ratios, sine, cosine and tangent. If you find any errors or miscalculations
here, please inform me.

2. THE SINE RATIO

To calculate the sine of an angle, the opposite is divided by the hypotenuse.
The sine ratio is abbreviated as sin.

Formula: sin ang = opp / hyp    (opposite is abbreviated as opp,
                                 hypotenuse is abbreviated as hyp)

Example: sin 30 deg = 4 / 8     (the angle calculated is 30 degrees,
         sin 30 deg = .5         the opposite is 4,
                                 the hypotenuse is 8)

     |\
     |  \               the adjacent is of no importance
     |    \     8       a is a right angle 
  4  |      \  hyp
 opp |        \
     |          \
     |            \
     | a        30  \
     |----------------
          adj (adjacent)

3. COSINE RATIO

To calculate the cosine of an angle, instead of dividing the opposite by the
hypotenuse, you divide the adjacent by the hypotenuse. Cosine is abbreviated
as cos.

Formula: cos ang = adj / hyp

Example: cos 60 deg = 3 / 6      (the angle calculated is 30 degrees,
         cos 60 deg = .5          the adjacent is 3,
                                  the hypotenuse is 6)

     |\
     |  \      6        this time the opposite is of no importance
     |    \   hyp       a is a right angle
 opp |      \
     |        \
     | a    60  \
     |------------
           3
          adj

4. THE TANGENT RATIO

The tangent of an angle is determined by dividing the opposite by the
adjacent. Tangent is abbreviated as tan.

Formula: tan ang = opp / adj

Example: tan 60 deg = 14 / 20     (the angle is 30 degrees,
         tan 60 deg = .7           the opposite is 14,
                                   the adjacent is 20)

     |
 14  |                  in this situation, the hypotenuse is ignored
 opp |           
     |         / hyp
     |       / 
     |     / 
     |   / 
     | /            30
     |------------------
            20
            adj

5. RATIOS AS PART OF A CIRCLE

Here the same techniques are demonstrated on a full rotation, with triangles
cut out. This is a more realistic example using X/Y co-ordinates.

                                        y

                                        |
                                      D | B
                              r         |         r (radius of the circle)
                                \       |       /
                                  \     |     /
                                    \   |   /
                           C  obtuse  \ | /   acute  A
                          --------------|-------------- x
                           E          / | \          G
                                    /   |   \
                                  /     |     \
                                /       |       \
                              r         |         r
                                      F | H
                              reflex    |    reflex

Try applying some of the techniques on this circle. Acute, obtuse and reflex
are the types of angles.

-----------------------------------------------------------------------------
 Copyright (C) 2000 Lionel Pinkhard. All Rights Reserved.
-----------------------------------------------------------------------------