Click to See Complete Forum and Search --> : Triangle Doctor
Amon Ra
Mar 7th, 2001, 07:59 PM
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 :) :)
Cybrg641
Mar 7th, 2001, 10:05 PM
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 :(.
HarryW
Mar 8th, 2001, 01:27 AM
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).
Amon Ra
Mar 8th, 2001, 08:41 AM
Ok, so the arcsin and arccos are already made?
Amon Ra
Mar 8th, 2001, 08:53 AM
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
Mar 8th, 2001, 08:55 AM
Sorry for asking so much, but the parameters of the sin or cos function look so weird. I dont get it :(
HarryW
Mar 8th, 2001, 09:00 AM
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.
Amon Ra
Mar 8th, 2001, 09:01 AM
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?
HarryW
Mar 8th, 2001, 09:05 AM
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.
HarryW
Mar 8th, 2001, 09:07 AM
I don't see what's complicated about the sin() and cos() functions.... have you used radians before?
Amon Ra
Mar 8th, 2001, 09:19 AM
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.
parksie
Mar 9th, 2001, 12:24 PM
Just in case...
2*pi radians = 360 degrees
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.