Results 1 to 6 of 6

Thread: The atan2() function of C++

  1. #1
    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!!!

  2. #2
    Join Date
    May 2008
    Posts
    2,012

    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>.

  3. #3
    Join Date
    May 2008
    Posts
    2,297

    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 );

  4. #4
    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.

  5. #5
    Join Date
    Apr 2008
    Posts
    2,005

    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.

  6. #6
    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

Similar Threads

  1. c++ equivalent function to the c-function 'sprintf
    By Dilbert in forum Software Development
    Replies: 6
    Last Post: 13-12-2011, 04:03 PM
  2. c# function equivalent to gettime function in javascript
    By Omaar in forum Software Development
    Replies: 4
    Last Post: 10-03-2010, 10:44 PM
  3. Replies: 5
    Last Post: 27-02-2010, 07:52 PM
  4. How does abstract function differs from virtual function?
    By Maddox G in forum Software Development
    Replies: 5
    Last Post: 29-01-2010, 11:32 AM
  5. Function keys don't function under windows XP
    By GunFighter in forum Hardware Peripherals
    Replies: 3
    Last Post: 08-04-2009, 11:07 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,726,798,097.75720 seconds with 17 queries