Results 1 to 12 of 12

Thread: Triangle Doctor

  1. #1

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500

    Wink

    I want to make a small program that will calculate any value in a triangle, when given the values either Side Side Side, Angle Side Angle or SideAngleSide. I did that in VB so with the little i know from C++, I would like to try doing the same thing(on a console for now). I just wanted to know: Are there sin, cos and tan functions in c++? Also, because i lost them , do any of u have a txt file with all the derived math functions such as arcsin and arccos? Thanx guys.

    PS : I feel bad cuz i ask you questions, but i cant help you much in c++ right now, so i appreciate thanks
    Amon Ra
    The Power of Learning.

  2. #2
    Lively Member
    Join Date
    Jun 2000
    Posts
    122
    Yes, there are functions for sine, cosine, and tangent but the arguments must be passed as radians not degrees. I don't know if you can do it in degrees or not .

  3. #3
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    The VB functions take parameters in radians too, so I don't think that's a problem.

    Just use

    #include <cmath>

    and you can use sin, cos and tan just like you can in VB. There are also acos(), asin() and atan() functions (also atan2() which takes different parameters if you want).
    Harry.

    "From one thing, know ten thousand things."

  4. #4

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500

    Wink Thanks

    Ok, so the arcsin and arccos are already made?
    Amon Ra
    The Power of Learning.

  5. #5

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500

    ??

    How come when i tried to include
    #include <cmath.h>
    it says cannot find such file or dir.
    when i enter it like this:
    3include <cmath> it works. Why cant i put an .h there??
    Amon Ra
    The Power of Learning.

  6. #6

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500

    Unhappy Sorry

    Sorry for asking so much, but the parameters of the sin or cos function look so weird. I dont get it
    Amon Ra
    The Power of Learning.

  7. #7
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Yep, the functions all there

    The standard way to include the STL headers is without a .h. MSVC++ will try to include Microsoft's own headers if you don't explicitly use the standard headers.

    In actual fact, in the case of <cmath> it just translates directly to #include <math.h> but in general you should stick to the standard ways of doing it so that you will get the standard headers if you compile with other compilers.
    Last edited by HarryW; Mar 8th, 2001 at 10:03 AM.
    Harry.

    "From one thing, know ten thousand things."

  8. #8

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500

    Cool Cool

    Cool it works. Thx. How could i truncate my double number at a specific place after the decimal point?
    And are you sure arcsin and arccos are there as well?
    Amon Ra
    The Power of Learning.

  9. #9
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    To format the number you'll have to make a formatted string. I don't know if there's a function to do that but it's not hard to do yourself.

    asin() and acos() are there, as I said.
    Harry.

    "From one thing, know ten thousand things."

  10. #10
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    I don't see what's complicated about the sin() and cos() functions.... have you used radians before?
    Harry.

    "From one thing, know ten thousand things."

  11. #11

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500

    Smile Ok

    ok nevermind i figured it out, thatkx, and for the arccos, i was writing arccos, but actually i have to write acos
    i guess i will stick with the standard cmath then. Thanks a lot.
    Amon Ra
    The Power of Learning.

  12. #12
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Just in case...

    2*pi radians = 360 degrees
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width