gcc-4.9 seems to be able to see that accessing p[1] in 1D is out of bound
for spacedim == 1 but it can omit the warning if accessed inside a switch
statement. Fix this warning (even though we won't use SphericalManifold
for spacedim == 1).
{
const Point<spacedim> R = space_point-center;
const double rho = R.norm();
- const double x = R[0];
- const double y = R[1];
Point<spacedim> p;
p[0] = rho;
switch (spacedim)
{
case 2:
- p[1] = atan2(y,x);
+ p[1] = atan2(R[1],R[0]);
if (p[1] < 0)
p[1] += 2*numbers::PI;
break;
case 3:
{
const double z = R[2];
- p[2] = atan2(y,x); // phi
+ p[2] = atan2(R[1],R[0]); // phi
if (p[2] < 0)
p[2] += 2*numbers::PI; // phi is periodic
- p[1] = atan2(sqrt(x*x+y*y),z); // theta
+ p[1] = atan2(sqrt(R[0]*R[0]+R[1]*R[1]),z); // theta
}
break;
default:
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