Let ox, oy, oz
be the center of your sphere. Then you just subtract the center from x, y, z
before doing your computation:
public bool getPoint (int x, int y, int z, int ox, int oy, int oz)
{
x -= ox;
y -= oy;
z -= oz;
return (x*x+y*y+z*z < r*r);
}
Note that the expression expr ? true : false
is equivalent to expr
regardless of what expr
is.