]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Avoid computing atan(y/x) where x=0. 1061/head
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 29 Jun 2015 23:01:45 +0000 (18:01 -0500)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 29 Jun 2015 23:10:02 +0000 (18:10 -0500)
Rather, use atan2(y,x).

tests/codim_one/bem_integration.cc

index 063d2dd28b737b8f7992fd63e278b56611e49461..9b03d82c9442c548fd45b8d71182af6c671f4512 100644 (file)
@@ -165,7 +165,7 @@ LaplaceKernelIntegration<dim>::term_S (const Tensor<1,3> &r,
     *(
       - ra1*n/a1.norm() * asinh( r*a1/ra1.norm() )
       + ra2*n/a2.norm() * asinh( r*a2/ra2.norm() )
-      + rn_c * atan( ra1*ra2 / (r.norm()* (r*(a12))))
+      + rn_c * atan2( ra1*ra2, r.norm()* (r*a12) )
     );
 
   return integral;
@@ -185,7 +185,7 @@ LaplaceKernelIntegration<dim>::term_D (const Tensor<1,3> &r,
   cross_product(a12,a1,a2);
 
   double integral = 1./2./numbers::PI
-                    *atan( ra1*ra2 / (r.norm()* (r*(a12))));
+                    *atan2( ra1*ra2, (r.norm()* (r*a12)));
 
   return integral;
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.