Beispiel #1
0
double CArg(CValue a_c)
{
	double pi_2 = 1.570796326795;
	double b    = 180/(2*pi_2);
    double x = a_c.real();
    double y = a_c.imag();
	double a;
	double s_x = (x != 0.0) ? x/fabs(x) : 1.0;
	double s_y = (y != 0.0) ? y/fabs(y) : 1.0;
    if(x != 0.0)
    {  a = atan(fabs(y)/fabs(x));
	   if(s_x < 0 && s_y > 0)
	      a = 2*pi_2 - a;
	   if(s_x < 0 && s_y < 0)
	      a = a - 2*pi_2;
	   if(s_x > 0 && s_y < 0)
	      a = -a;
	   return(a*b);
	}
    else
    {  if(y == 0)
	      return(0.);
       if(s_y > 0)
		  a = pi_2;
	   else
		  a = -pi_2;
	   return(a*b);
    }
}
Beispiel #2
0
double CMod(CValue a)
{
    double x = a.real();
    double y = a.imag();
    return(sqrt(x*x + y*y));
}