public static void Write(string fileName, Molecule moleculeA, Molecule moleculeB, Transformation transform, float value) { new Output(fileName, moleculeA, moleculeB, transform, value); }
public Grid(Molecule moleculeA, Molecule moleculeB) { scale = 1 / dimension; maxDistanceSquared = maxDistance * maxDistance; this.moleculeA = moleculeA; this.moleculeB = moleculeB; for (int i = 0; i < moleculeA.Size; i++) { Block block = GetBlock(moleculeA.GetAtom(i)); if (block.X < minX) { minX = block.X; } if (block.X > maxX) { maxX = block.X; } if (block.Y < minY) { minY = block.Y; } if (block.Y > maxY) { maxY = block.Y; } if (block.Z < minZ) { minZ = block.Z; } if (block.Z > maxZ) { maxZ = block.Z; } } // Add small buffer to all edges int edge = (int)Math.Ceiling(4 * maxDistance * scale); minX -= edge; minY -= edge; minZ -= edge; maxX += edge; maxY += edge; maxZ += edge; rangeX = maxX - minX + 1; rangeY = maxY - minY + 1; rangeZ = maxZ - minZ + 1; blocks = rangeX * rangeY * rangeZ; atomsInBlock = new int[blocks]; blockStartIndex = new int[blocks]; int atomIndicesSize = 0; forEachBlockAndAtom((block, atom) => { atomsInBlock[GetIndex(block)]++; atomIndicesSize++; }); int pos = 0; for (int i = 0; i < blocks; i++) { blockStartIndex[i] = pos; pos += atomsInBlock[i]; atomsInBlock[i] = 0; } atomIndices = new int[atomIndicesSize]; forEachBlockAndAtom((block, atom) => { int i = GetIndex(block); atomIndices[blockStartIndex[i] + atomsInBlock[i]] = atom; atomsInBlock[i]++; }); }