<math.h> functions

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2009
Posts: 12
Reputation: chrishtones is an unknown quantity at this point 
Solved Threads: 1
chrishtones's Avatar
chrishtones chrishtones is offline Offline
Newbie Poster

<math.h> functions

 
-1
  #1
Jul 9th, 2009
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?
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,681
Reputation: Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all 
Solved Threads: 264
Lerner Lerner is offline Offline
Posting Virtuoso

Re: <math.h> functions

 
1
  #2
Jul 9th, 2009
Hard time converting radians to angles?
Klatu Barada Nikto
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 12
Reputation: chrishtones is an unknown quantity at this point 
Solved Threads: 1
chrishtones's Avatar
chrishtones chrishtones is offline Offline
Newbie Poster

Re: <math.h> functions

 
0
  #3
Jul 9th, 2009
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?
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 8
Reputation: bnekolny is an unknown quantity at this point 
Solved Threads: 0
bnekolny bnekolny is offline Offline
Newbie Poster

Re: <math.h> functions

 
0
  #4
Jul 9th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 1,607
Reputation: jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of 
Solved Threads: 120
jephthah's Avatar
jephthah jephthah is offline Offline
Posting Virtuoso

Re: <math.h> functions

 
0
  #5
Jul 9th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 12
Reputation: chrishtones is an unknown quantity at this point 
Solved Threads: 1
chrishtones's Avatar
chrishtones chrishtones is offline Offline
Newbie Poster

Re: <math.h> functions

 
0
  #6
Jul 9th, 2009
Thank You!!!
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 12
Reputation: chrishtones is an unknown quantity at this point 
Solved Threads: 1
chrishtones's Avatar
chrishtones chrishtones is offline Offline
Newbie Poster

Re: <math.h> functions

 
0
  #7
Jul 9th, 2009
Yes that does help thank you!
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 12
Reputation: chrishtones is an unknown quantity at this point 
Solved Threads: 1
chrishtones's Avatar
chrishtones chrishtones is offline Offline
Newbie Poster

Re: <math.h> functions

 
0
  #8
Jul 9th, 2009
What header do I use for arcsin()?
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 1,607
Reputation: jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of 
Solved Threads: 120
jephthah's Avatar
jephthah jephthah is offline Offline
Posting Virtuoso

Re: <math.h> functions

 
0
  #9
Jul 9th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 16,200
Reputation: jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all 
Solved Threads: 538
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is online now Online
Moderator

Re: <math.h> functions

 
-7
  #10
Jul 9th, 2009
Cant you just convert the radians to degrees?
If i am helpful, please give me reputation points.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC