Thread: How to write COS, TAN, SIN

  1. #1
    Registered User
    Join Date
    Jul 2013
    Location
    Germany
    Posts
    499

    Lightbulb How to write COS, TAN, SIN

    I know I need <math.h> and I know how to write tan(10) or whatever I need. However I need angles, like 100 / tan10 = 567.13. The 10 is degrees.

    I am doing a fun project now that I feel more confident. However my textbook only shows me how to use the math library and only shows a few trig functions.

    I am applying Trigonometric Functions to see if a car is speeding.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    If you are asking how to use those functions to work with degrees, then a solution is to convert the value in degrees to/from radians.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    Angles must be in radians.
    Code:
    #define PI 3.141592653589793
    #define DEG_TO_RAD(d) ((d)*(PI/180.0))
    
    double x = 100.0 / tan(DEG_TO_RAD(10));
    But it's more efficient to just work with radians.

  4. #4
    Registered User
    Join Date
    Jul 2013
    Location
    Germany
    Posts
    499
    Thank you... I got it...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. what to write
    By lukasjob in forum C Programming
    Replies: 8
    Last Post: 04-02-2011, 03:54 AM
  2. Write in txt...
    By Ervilha in forum C Programming
    Replies: 1
    Last Post: 10-07-2009, 12:18 PM
  3. problem with fout.write: cannot write 0x0A (10 dec)
    By yvesdefrenne in forum C++ Programming
    Replies: 7
    Last Post: 05-23-2005, 12:53 PM
  4. write to hex, is it possible?
    By keithmolo in forum C++ Programming
    Replies: 12
    Last Post: 07-30-2003, 02:27 PM