943,975 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 2398
  • C++ RSS
You are currently viewing page 1 of this multi-page discussion thread
Jul 9th, 2009
-1

<math.h> functions

Expand Post »
Is there any way that I can get the sin(), cos() and tan() functions to return an angle? For example, like when you press 2nd then sin on a calculator. Or should I use different functions?
Similar Threads
Reputation Points: 10
Solved Threads: 1
Newbie Poster
chrishtones is offline Offline
16 posts
since Jun 2009
Jul 9th, 2009
1

Re: <math.h> functions

Hard time converting radians to angles?
Reputation Points: 718
Solved Threads: 373
Nearly a Posting Maven
Lerner is offline Offline
2,253 posts
since Jul 2005
Jul 9th, 2009
0

Re: <math.h> functions

I am new at this. I am trying to make a little top down 2D game where the character rotates towards the mouse. Got any ideas?
Reputation Points: 10
Solved Threads: 1
Newbie Poster
chrishtones is offline Offline
16 posts
since Jun 2009
Jul 9th, 2009
0

Re: <math.h> functions

So, I think the previous post was alluding to the fact that:

degrees = radians * 180/pi

Hope that helps?
Last edited by bnekolny; Jul 9th, 2009 at 8:09 pm.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bnekolny is offline Offline
8 posts
since Jul 2009
Jul 9th, 2009
0

Re: <math.h> functions

i belive what you are looking to use are the acos(), asin(), and atan() functions.

for instance: tan() returns the ratio of the sides (y/x or opposite/adjacent) when given the angle in radians as the argument .... whereas atan() returns the angle in radians, when given the ratio of the sides ( y/x or opposite/adjacent) as the argument.

('arctan' -- called 'atan' here -- is the inverse function of 'tan'. it is the one that is actually used when you use the 2nd key on your calculator in conjunction with 'tan'. And as mentioned, angles are in radians. to convert to degrees, muliply the radian value by 180/pi)


[edit] the functions are called as "atan"... not "arctan" as i originally typed. sorry[/edit]


.
Last edited by jephthah; Jul 9th, 2009 at 8:40 pm.
Reputation Points: 2143
Solved Threads: 178
Posting Maven
jephthah is offline Offline
2,567 posts
since Feb 2008
Jul 9th, 2009
0

Re: <math.h> functions

Thank You!!!
Reputation Points: 10
Solved Threads: 1
Newbie Poster
chrishtones is offline Offline
16 posts
since Jun 2009
Jul 9th, 2009
0

Re: <math.h> functions

Yes that does help thank you!
Reputation Points: 10
Solved Threads: 1
Newbie Poster
chrishtones is offline Offline
16 posts
since Jun 2009
Jul 9th, 2009
0

Re: <math.h> functions

What header do I use for arcsin()?
Reputation Points: 10
Solved Threads: 1
Newbie Poster
chrishtones is offline Offline
16 posts
since Jun 2009
Jul 9th, 2009
0

Re: <math.h> functions

sorry, i made a typing mistake .. in C/C++ the functions are actually called as "asin()", "acos()" and "atan()"

follow the links i provided above and you'll see the prototypes.

the header is still the same <math.h> (aka <cmath>)

.
Last edited by jephthah; Jul 9th, 2009 at 8:45 pm.
Reputation Points: 2143
Solved Threads: 178
Posting Maven
jephthah is offline Offline
2,567 posts
since Feb 2008
Jul 9th, 2009
-7

Re: <math.h> functions

Cant you just convert the radians to degrees?
Moderator
Featured Poster
Reputation Points: 1800
Solved Threads: 575
Moderator
jbennet is offline Offline
16,520 posts
since Apr 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: ofstream doesn't work or the first line isn't run
Next Thread in C++ Forum Timeline: Dark GDK rotation





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC