Wednesday, April 24, 2024 | Toby Opferman
 

Unit Circle & Trig Functions

Toby Opferman
http://www.opferman.net
toby@opferman.net


  			     Triginometry


	Welcome to trignometric functions and circles.  


First let me introduce you the trignometric functions & Names.               
cos(theta)  = x/r = Cosine
sin(theta)  = y/r = Sine
tan(theta)  = y/x = Tangent

1/cos(theta)  = sec(theta) = r/x = Secant
1/sin(theta)  = csc(theta) = r/y = Cosecant
1/tan(theta)  = cot(theta) = x/y = Cotangent


What the trignometric functions do:

Let's pretend this ugly shit is a real circle that intersects at
(1,0) (0,1) (-1,0) (0, -1) on the axies.


        ^
      . . .
     .  |   . 
    .   |    .   
<---.---+-----.----->
     .  |   .
       ... .
        |
        |

This is the unit circle.

What the trignometric functions do is give us information about a point
on the circle.


For instance.  

Each 
          90
           ^
    135    |    45
           |   
          \|/   
180 <------+-------> 0 (360)
          /|\   
           |
   225     |   315 
           |
          270


Each direction from the origin has an angle.  If you want to know the
location of a place on the circle you would use the Trig Functions.

For instance. If we have a circle of size r.  To find the
X value at degree 0 we would cos(0) = x/r

Let us take the unit circle as above

cos(0) = 1/1 = 1
sin(0) = 0/1 = 0

Hence, (1, 0)  is on the unit circle.




If your radius is not 1 then you would want to do the following:

cos(theta)*r  = x
sin(theta)*r  = y


If your radius is 20, then

cos(0)*20 = 1/1 * 20 = 20

Remeber, even though this works out, it always returns the value as if
it was radius 1.  But, you can treat the R as it if was the R since it works out.

In theory it would be:
cos(0)*20 = 20/20 * 20 = 20  

But it works out the same.


Now, there is another form of measurement called radians.

180 is half circle.  PI is half circle in radians.


          PI/2
           ^
    3PI/4  |    PI/4
           |   
          \|/   
PI  <------+-------> 0 (2PI)
          /|\   
           |
   5PI/4   |   7PI/4
           |
         3PI/2  


To convert from Degrees to Radians:

Angle*PI/180 = Radians

To Convert from Raidans to Degrees:

Radians*180/PI = Degrees


180 and PI are equivlent in the systems.  



There are also inverse Trig Functions:

arccos or cos^-1
arcsin or sin^-1
arctan or tan^-1

Where:

cos^-1(x/r) = theta
sin^-1(y/r) = theta
tan^-1(y/x) = theta

So

tan^-1(tan(theta)) = theta

and

tan(tan^-1(y/x)) = y/x


At any point on the circle you can form a triangle.

        /|
       / |
      /  |
     /   |
  R /    | Y
   /     |
  /      |
 /Theta  |
/_@______| 
    X

The X is how far it comes out along the X axis, the Y is how far up obviously.
R is a direct line from origin to (X,Y) at an angle.

If you read the vectors tutorial you could represent these as vectors:

Since adding two vectors that are on top of each other gets you the connecting
vector:

 + <0, Y> =  sqrt(X^2 + Y^2) = R

R is the length.

R = 


Always remeber this equation:

X^2 + Y^2 = R^2

and

R = Sqrt(X^2 + Y^2)

Also remeber that this is for circle at center 0,0


(X - h)^2 + (Y - k)^2 = R^2


For circles at center (h, k)

The reason that (X - h) is - and not + is because of this:

Center x = 1, X intercept = X = 5

   0   1       5
---+---|-------*>
          
 All trignometric functions work at the origin, so you have to 
adjust the circle to be at the origin.
5 - 1 = 4.  From 5 to 1 is a X of 4, which would be a radius of 4.
If the graph was at the origin the X component would be 4 not 5.   


-1  0          5
-|--+----------*>

If Center was -1, then 5 - -1 = 5 + 1 = 6

That's a length of 6.  You shift the graph over to be correct at the origin
so the trignometric functions can work correctly.


To go backwards, you can have negative angles.

-45 degrees = 315 degrees.

If you want to convert any angle to be from 0-360, you just
keep subtracting or adding 360 (2PI) until you get an angle/radian
in that range and it will be equivlent.


cos^2(theta) + sin^2(theta) = 1  at all times.

To do a simple proof of this we can show using a vector
You know a vector is a length and a direction.

r



Now, we want to find the radius.

Sqrt((r*cos(theta))^2 + (r*sin(theta))^2)

Sqrt(r^2*cos(theta)^2 + r^2*sin(theta)^2)

Notice now that r^2 is a common term.

Sqrt(r^2*(cos(theta)^2 + sin(theta)^2))

Now, notice that Radius = Length = r.

Notice there is an r^2 in there and that is a squareroot function.

And we know the answer is supposed to be r.  
cos(theta)^2 + sin(theta)^2  would have to be 1 in order for this to work out
correctly.  (theta must equal theta, they both must be the same)

Sqrt(r^2*1) = r


cos^2(0) + sin^2(0) = 1 + 0 = 1

cos^2(45) + sin^2(45) = .5 + .5 = 1



There are other properties of trignometric functions

sin(theta)
---------   =  tan(theta)
cos(theta)


Some are easy to see like the above.

Here are some others:

sin(2x) = 2sin(x)cos(x)

cos(2x) = cos^2(x) - sin^2(x) = 2cos^2(x) - 1 = 1 - 2sin^2(x)

tan(2x) = 2tan(x)/(1 - tan^2(x))

sin^2(x) = (1-cos(2x))/2

cos^2(x) = (1+cos(2x))/2

tan^2(x) = (1-cos(2x))/(1+cos(2x))

sin(x) + sin(y) = 2sin((x+y)/2)cos((x-y)/2)

sin(x) - sin(y) = 2cos((x+y)/2)sin((x-y)/2)

cos(x) + cos(y) = 2cos((x+y)/2)cos((x-y)/2)

cos(x) - cos(y) = -2sin((x+y)/2)sin((x-y)/2)

sin(x)sin(y) = 1/2(cos(x-y) - cos(x+y))

cos(x)cos(y) = 1/2(cos(x-y) + cos(x+y))

sin(x)cos(y) = 1/2(sin(x+y) + sin(x-y))

cos(x)sin(y) = 1/2(sin(x+y) - sin(x-y))

1 + tan^2(x) = sec^2(x)

1 + cot^2(x) = csc^2(x)

sin(PI/2 - x) = cos(x)
csc(PI/2 - x) = sec(x)
sec(PI/2 - x) = csc(x)
cos(PI/2 - x) = sin(x)
tan(PI/2 - x) = cot(x)
cot(PI/2 - x) = tan(x)

sin(-x) = -sin(x)
csc(-x) = -csc(x)
sec(-x) = sec(x)
cos(-x) = cos(x)
tan(-x) = -tan(x)
cot(-x) = -cot(x)

sin(x +/- y) = sin(x)cos(y) +/- cos(x)sin(y)
cos(x +/- y) = cos(x)cos(y) -/+ sin(x)sin(y)
tan(x +/- y) = (tan(x) +/- tan(y))/(1 -/+ tan(x)tan(y))


*NOTE* Look at the +/- order!!!! It's purposes put in those fashions.
 
About Toby Opferman

Professional software engineer with over 15 years...

Learn more »
Codeproject Articles

Programming related articles...

Articles »
Resume

Resume »
Contact

Email: codeproject(at)opferman(dot)com