Vector3 SphereGridTopology::getPointInGrid(int i, int j, int k) const { //return p0+dx*x+dy*y+dz*z; SReal r = d_radius.getValue(); Vector3 axisZ = d_axis.getValue(); axisZ.normalize(); Vector3 axisX = ((axisZ-Vector3(1,0,0)).norm() < 0.000001 ? Vector3(0,1,0) : Vector3(1,0,0)); Vector3 axisY = cross(axisZ,axisX); axisX = cross(axisY,axisZ); axisX.normalize(); axisY.normalize(); axisZ.normalize(); int nx = getNx(); int ny = getNy(); int nz = getNz(); // coordonate on a square Vector3 p(i*2*r/(nx-1) - r, j*2*r/(ny-1) - r, k*2*r/(nz-1) - r); // scale it to be on a circle if (p.norm() > 0.0000001){ SReal maxVal = helper::rmax(helper::rabs(p[0]),helper::rabs(p[1])); maxVal = helper::rmax(maxVal,helper::rabs(p[2])); p *= maxVal/p.norm(); } return d_center.getValue()+axisX*p[0] + axisY*p[1] + axisZ * p[2]; }
Box3D AtomicBlock3D::getBoundingBox() const { return Box3D(0, getNx()-1, 0, getNy()-1, 0, getNz()-1); }