|
-
Mar 7th, 2001, 08:59 PM
#1
Thread Starter
Hyperactive Member
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.
-
Mar 7th, 2001, 11:05 PM
#2
Lively Member
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 .
-
Mar 8th, 2001, 02:27 AM
#3
Frenzied Member
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."
-
Mar 8th, 2001, 09:41 AM
#4
Thread Starter
Hyperactive Member
Thanks
Ok, so the arcsin and arccos are already made?
Amon Ra
The Power of Learning.
-
Mar 8th, 2001, 09:53 AM
#5
Thread Starter
Hyperactive Member
??
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.
-
Mar 8th, 2001, 09:55 AM
#6
Thread Starter
Hyperactive Member
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.
-
Mar 8th, 2001, 10:00 AM
#7
Frenzied Member
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."
-
Mar 8th, 2001, 10:01 AM
#8
Thread Starter
Hyperactive Member
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.
-
Mar 8th, 2001, 10:05 AM
#9
Frenzied Member
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."
-
Mar 8th, 2001, 10:07 AM
#10
Frenzied Member
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."
-
Mar 8th, 2001, 10:19 AM
#11
Thread Starter
Hyperactive Member
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.
-
Mar 9th, 2001, 01:24 PM
#12
Monday Morning Lunatic
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|