Stupid Question:

This is a discussion on Stupid Question: within the A Brief History of Cprogramming.com forums, part of the Community Boards category; What are sine, cosine, and tangent? Constants? Functions? ...And how are they useful? The only use for them I know ...

  1. #1
    People Love Me
    Join Date
    Jan 2003
    Posts
    412

    Stupid Question:

    What are sine, cosine, and tangent? Constants? Functions?

    ...And how are they useful?

    The only use for them I know is the:

    angle degree = -tan(o/a)

    Other than that, I know pretty much nothing about the 3. =\

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Take some trig and learn

    In the basic way is that from an Angle:
    sine is the ratio of the opposite leg to the hypotenuse
    cosine is the ratio of the adjucent leg to the hypotenuse
    Tangent is the ratio of the opposite leg to the adjucent leg
    Last edited by Thantos; 03-07-2004 at 08:52 PM.

  3. #3
    People Love Me
    Join Date
    Jan 2003
    Posts
    412
    Originally posted by Thantos
    Take some trig and learn

    In the basic way is that from an Angle:
    sine is the ratio of the opposite leg to the hypotenuse
    cosine is the ratio of the adjucent leg to the hypotenuse
    Tangent is the ratio of the opposite leg to the adjucent leg
    I already knew that too, I just don't know any useful applications for them. =\

  4. #4
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    They are used for solving triangles. Honestly you'll need to take Trig to get the full usefullness of them.

  5. #5
    ...
    ... is offline
    Registered User
    Join Date
    Feb 2002
    Posts
    465
    the sine, cosine and tangent are basically ratios of the lenghths of two sides of a triangle.

    take for example, the scenario where you know an angle of a right triangle and the length of one of the sides, and you need to find out the length of one of the other sides. you would then work out via algebra whether to multiply or divide the result of the sin, cos, or tan ( depending on what side you have / need ) by the length of the side you have

    Code:
       |\
       | \
       |  \
       |   \  5
     x |    \
       |     \ 
       |___30 \
         y
    here, where 30 is the measure of that angle, and 5 is the length of the hypotenuse, you could work out the remaining sides as follows:

    sin( 30 ) * 5 = the length of x
    cos( 30 ) * 5 = the length of y


    trig is really useful for solving these types of equations. in computer game programming (which i am into more than any other realm of programming) we dont normally use trig where we can avoid it, because trig functions are slow. game programmers spend most of their time with linear algebra and vectors and stuff, but that doesnt mean it isnt still used on occasion.
    Last edited by ...; 03-07-2004 at 09:16 PM.
    I came up with a cool phrase to put down here, but i forgot it...

  6. #6
    ...
    ... is offline
    Registered User
    Join Date
    Feb 2002
    Posts
    465
    oops, disregard... double post
    I came up with a cool phrase to put down here, but i forgot it...

  7. #7
    Registered User
    Join Date
    May 2003
    Posts
    195
    Well as ... mentions, they are used for finding sides of triangles. Especially when u get into advanced math sin, cos, and tan are especially useful. Also if ur gonna go into triangles, know some trig identities

  8. #8
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    Code:
    #define PI 3.14159
    #define MAX_X     640
    #define MIN_X     0
    #define MAX_Y     480
    #define MIN_Y     0
    #define DEGTORAD(x)  ((double)x*PI/180.0)
    
    struct point2D
    {
      double x;
      double y;
    };
    
    
    
    class Bullet
    {
      point2D Screen;
      point2D Velocity;
      int Angle;
      public:
         Bullet(point2D tScreen,int tAngle);
         void Move(void);
    };
    
    
    Bullet::Bullet(point2D tScreen,int tAngle)
    {
      Angle=tAngle;
      Screen=tScreen;
      Velocity.x=cos(DEGTORAD(tAngle));
      Velocity.y=sin(DEGTORAD(tAngle));
    };
    
    void Bullet::Move(void)
    {
       Screen.x+=Velocity.x;
       Screen.y+=Velocity.y;
    
       if (Screen.x>=MAX_X) Velocity.x=-Velocity.x;
       if  (Screen.x<=MIN_X) Velocity.x=-Velocity.x;
       if (Screen.y>=MAX_Y) Velocity.y=-Velocity.y;
       if (Screen.y<=MIN_Y) Velocity.y=-Velocity.y;
    }
    In this snippet COS and SIN get the correct component increments for x and y for the given angle.

    EDIT: I forgot to place the return type in front of my move() function member.
    Last edited by VirtualAce; 03-08-2004 at 04:18 PM.

  9. #9
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Google for "Computer Graphics" sin cos tan will all make appearances on those related pages.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  10. #10
    Banned nickname_changed's Avatar
    Join Date
    Feb 2003
    Location
    Australia
    Posts
    986
    They also pop up a lot in physics, like finding the horizontal and vertical velocities of a ball kicked at say 30 degrees at 15 k's an hour. That will let you calculate how long the ball will go, how high etc.

    I would also expect it to pop up a lot in architecture and any forms of engineering.

    As a pleb you'll probably not have any use for it, but if your going for a professional career like engineering or even in IT they might just come in handy. Plus they are fun to learn (IMHO) and the problem solving aspects alone are worth learning.

    Functions can be a lot of fun. Lets say you have a graph of say y = 5x + 3.

    This could also be written as f(x) (ie, a function of x) = 5x +3

    They come up a lot when your finding things like the derivative of a graph, ie. the instantaneous speed of a graph of distance vs time at a given point X.

    Constants are just numbers. Pie is a constant, so is 5, 10002, -111000 and 0. Their values never change, so they are constant.
    Last edited by nickname_changed; 03-08-2004 at 01:33 AM.

  11. #11
    Rad gcn_zelda's Avatar
    Join Date
    Mar 2003
    Posts
    942
    Sines, cosines, and tangents can also be used with circles, I believe, but, hey, I'm starting Adv. Trig in High School next year...

  12. #12
    The Defective GRAPE Lurker's Avatar
    Join Date
    Feb 2003
    Posts
    949
    Wow! Bubba posted code without assembler in it!
    Do not make direct eye contact with me.

  13. #13
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    Wow! Bubba posted code without assembler in it!



    Yes, it does happen every now and then.

    Most of that would be a real mess in assembler and you probably wouldn't gain much for your troubles.

    So I beg for forgiveness from the assembly gods because Bubba hath failed thee this time.


  14. #14
    'AlHamdulillah
    Join Date
    Feb 2003
    Posts
    790
    Sines, cosines, and tangents can also be used with circles, I believe, but, hey, I'm starting Adv. Trig in High School next year...
    yeah, a circle is defined as:

    X^2 + Y^2 = R^2

    where R is the radius of the circle. a unit circle can be defined using trigonometric functions as:

    cos^2 x + sin^2 x = 1

  15. #15
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    X^2 + Y^2 = R^2
    I didn't know the eqation for a circle had XOR in it

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stupid Question Probably
    By Kyrin in forum C Programming
    Replies: 2
    Last Post: 05-07-2006, 12:51 AM
  2. Replies: 7
    Last Post: 11-03-2005, 11:17 PM
  3. Stupid Question
    By digdug4life in forum C++ Programming
    Replies: 22
    Last Post: 05-17-2005, 11:43 AM
  4. stupid, stupid question
    By xelitex in forum C++ Programming
    Replies: 5
    Last Post: 12-22-2004, 07:22 PM
  5. Stupid question: What does Debugger do?
    By napkin111 in forum C++ Programming
    Replies: 6
    Last Post: 05-02-2002, 10:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21