Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 10-03-2010
Member
 
Join Date: Dec 2009
Posts: 31
The atan2() function of C++

I am the studying in the BSC-IT. I can have the good knowledge of the C++ language. But I can not have much more knowledge about the built-in functions of C++ language. So, I want to know about the atan2() function of the C++ language. I also want to know about how can I use the atan2() function in the C++ programming language. Thus, Can anyone has the proper answer on the atan2() function in the C++ language. Reply Me!!!
Reply With Quote
  #2  
Old 10-03-2010
Member
 
Join Date: May 2008
Posts: 2,008
Re: The atan2() function of C++

The atan2() function of the C++ language can be used to compute an arc of a tangent with two arguments. The atan2() function can returns the principal value of an arc tangent of q/p that can be an expressed in radians. To calculate the value, the function that can uses the sign of both an arguments to determine the quadrant. In C++ language, the atan2() function can be overloaded in the <valarray>.
Reply With Quote
  #3  
Old 10-03-2010
Member
 
Join Date: May 2008
Posts: 2,293
Re: The atan2() function of C++

The atan2() function can compute an arc of the tangent with two arguments. The atan2() function of the C++ can returns the principal value of an arc of the tangent of b/a and that can be an expressed in radians. The following can be the general syntax of the atan2() function of the C++ language :
Code:
double atan2 (      double q,      double p );
long double atan2 ( long double q, long double p );
      float atan2 (       float q,       float p );
Reply With Quote
  #4  
Old 10-03-2010
Member
 
Join Date: Apr 2008
Posts: 1,948
The atan2() function of C++

The following program could states you that how you can use the atan2() function in the C++ language coding while using the atan2() function in the coding as shown :
Code:
#include <stdio.h>
#include <math.h>
#define PI 3.14159265
int main ()
{
  double p, q, rslt;
  p = -10.0;
  q = 10.0;
  result = atan2 (q,p) * 180 / PI;
  printf ("The arc tangent for (p=%lf, q=%lf) is %lf degrees\n", p, q, rslt);
  return 0;
}
Output:
Code:
The arc tangent for (p=-10.000000, q=10.000000) is 135.000000 degrees.
Reply With Quote
  #5  
Old 10-03-2010
Member
 
Join Date: Apr 2008
Posts: 2,001
Re: The atan2() function of C++

The atan2() function can calculates an arc of the tangent of q/p, by using the signs of an arguments to calculate the quadrant of the return value. The values that can be returned can be in the given specified range [-pi, pi]. You have to noticed that an order of the given specified an arguments can be passed to the atan2() function.
Reply With Quote
  #6  
Old 10-03-2010
Member
 
Join Date: Nov 2005
Posts: 1,323
Re: The atan2() function of C++

I can suggest you that to carefully go through the following code of lines that can demonstrates you how to use the atan2() function in the C++ programming as follows :
Code:
#include <math.h>
#include <stdio.h>
#include <errno.h>
int main( int ac, char* av[] ) 
{
   double z1, z2, z;
   if( ac != 3 )
{
      fprintf( stderr, "Usage: %s <z1> <z2>\n", av[0] );
      return;
   }
   z1 = atof( av[1] );
   z = atan( z1 );
   printf( "Arctangent of %f: %f\n", z1, z );
   z2 = atof( av[2] );
   z = atan2( z1, z2 );
   printf( "Arctangent of %f / %f: %f\n", z1, z2, z ); 
}
Output
Code:
Arctangent of 0.500000: 0.463648
Arctangent of 0.500000 / 5.000000: 0.099669
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "The atan2() function of C++"
Thread Thread Starter Forum Replies Last Post
c++ equivalent function to the c-function 'sprintf Dilbert Software Development 6 13-12-2011 04:03 PM
c# function equivalent to gettime function in javascript Omaar Software Development 4 10-03-2010 10:44 PM
How to pass function with parameters to another function in PHP? Linoo Software Development 5 27-02-2010 07:52 PM
How does abstract function differs from virtual function? Maddox G Software Development 5 29-01-2010 11:32 AM
Function keys don't function under windows XP GunFighter Hardware Peripherals 3 08-04-2009 11:07 PM


All times are GMT +5.5. The time now is 05:31 PM.