Exemple #1
0
        private Vector3[][] AtomicSurfacePoints(NeighborList nbrlist, int currAtomIdx, IAtom atom, Tessellate tess)
        {
            double totalRadius      = PeriodicTable.GetVdwRadius(atom.Symbol).Value + solventRadius;
            double totalRadius2     = totalRadius * totalRadius;
            double twiceTotalRadius = 2 * totalRadius;

            int[]      nlist = nbrlist.GetNeighbors(currAtomIdx);
            double[][] data  = Arrays.CreateJagged <double>(nlist.Length, 4);
            for (int i = 0; i < nlist.Length; i++)
            {
                double x12 = atoms[nlist[i]].Point3D.Value.X - atom.Point3D.Value.X;
                double y12 = atoms[nlist[i]].Point3D.Value.Y - atom.Point3D.Value.Y;
                double z12 = atoms[nlist[i]].Point3D.Value.Z - atom.Point3D.Value.Z;

                double d2  = x12 * x12 + y12 * y12 + z12 * z12;
                double tmp = PeriodicTable.GetVdwRadius(atoms[nlist[i]].Symbol).Value + solventRadius;
                tmp = tmp * tmp;
                double thresh = (d2 + totalRadius2 - tmp) / twiceTotalRadius;

                data[i][0] = x12;
                data[i][1] = y12;
                data[i][2] = z12;
                data[i][3] = thresh;
            }

            Vector3[]        tessPoints = tess.GetTessAsPoint3ds();
            List <Vector3[]> points     = new List <Vector3[]>();

            for (int i = 0; i < tessPoints.Length; i++)
            {
                Vector3 pt     = tessPoints[i];
                bool    buried = false;
                for (int j = 0; j < data.Length; j++)
                {
                    if (data[j][0] * pt.X + data[j][1] * pt.Y + data[j][2] * pt.Z > data[j][3])
                    {
                        buried = true;
                        break;
                    }
                }
                if (buried == false)
                {
                    Vector3[] tmp = new Vector3[2];
                    tmp[0] = new Vector3(totalRadius * pt.X + atom.Point3D.Value.X, totalRadius * pt.Y
                                         + atom.Point3D.Value.Y, totalRadius * pt.Z + atom.Point3D.Value.Z);
                    tmp[1] = pt;
                    points.Add(tmp);
                }
            }

            // the first column contains the transformed points
            // and the second column contains the points from the
            // original unit tesselation
            Vector3[][] ret = Arrays.CreateJagged <Vector3>(points.Count, 2);
            for (int i = 0; i < points.Count; i++)
            {
                Vector3[] tmp = points[i];
                ret[i][0] = tmp[0];
                ret[i][1] = tmp[1];
            }
            return(ret);
        }