Пример #1
0
        /// <summary>
        /// Checks these 6 atoms to see if they form a trigonal-bipyramidal shape.
        /// </summary>
        /// <param name="atomA">one of the axial atoms</param>
        /// <param name="atomB">the central atom</param>
        /// <param name="atomC">one of the equatorial atoms</param>
        /// <param name="atomD">one of the equatorial atoms</param>
        /// <param name="atomE">one of the equatorial atoms</param>
        /// <param name="atomF">the other axial atom</param>
        /// <returns>true if the geometry is trigonal-bipyramidal</returns>
        public static bool IsTrigonalBipyramidal(IAtom atomA, IAtom atomB, IAtom atomC, IAtom atomD, IAtom atomE, IAtom atomF)
        {
            Vector3 pointA = atomA.Point3D.Value;
            Vector3 pointB = atomB.Point3D.Value;
            Vector3 pointC = atomC.Point3D.Value;
            Vector3 pointD = atomD.Point3D.Value;
            Vector3 pointE = atomE.Point3D.Value;
            Vector3 pointF = atomF.Point3D.Value;

            bool isColinearABF = StereoTool.IsColinear(pointA, pointB, pointF);

            if (isColinearABF)
            {
                // the normal to the equatorial plane
                Vector3 normal = StereoTool.GetNormal(pointC, pointD, pointE);

                // get the side of the plane that axis point A is
                TetrahedralSign handednessCDEA = StereoTool.GetHandedness(normal, pointC, pointF);

                // get the side of the plane that axis point F is
                TetrahedralSign handednessCDEF = StereoTool.GetHandedness(normal, pointC, pointA);

                // in other words, the two axial points (A,F) are on opposite sides
                // of the equatorial plane CDE
                return(handednessCDEA != handednessCDEF);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        private static TetrahedralSign GetHandedness(Vector3 pointA, Vector3 pointB, Vector3 pointC, Vector3 pointD)
        {
            // assumes anti-clockwise for a right-handed system
            Vector3 normal = StereoTool.GetNormal(pointA, pointB, pointC);

            // it doesn't matter which of points {A,B,C} is used
            return(StereoTool.GetHandedness(normal, pointA, pointD));
        }
Пример #3
0
        /// <summary>
        /// Gets the tetrahedral handedness of four atoms - three of which form the
        /// 'base' of the tetrahedron, and the other the apex. Note that it assumes
        /// a right-handed coordinate system, and that the points {A,B,C} are in
        /// a counter-clockwise order in the plane they share.
        /// </summary>
        /// <param name="baseAtomA">the first atom in the base of the tetrahedron</param>
        /// <param name="baseAtomB">the second atom in the base of the tetrahedron</param>
        /// <param name="baseAtomC">the third atom in the base of the tetrahedron</param>
        /// <param name="apexAtom">the atom in the point of the tetrahedron</param>
        /// <returns>the sign of the tetrahedron</returns>
        public static TetrahedralSign GetHandedness(IAtom baseAtomA, IAtom baseAtomB, IAtom baseAtomC, IAtom apexAtom)
        {
            Vector3 pointA = baseAtomA.Point3D.Value;
            Vector3 pointB = baseAtomB.Point3D.Value;
            Vector3 pointC = baseAtomC.Point3D.Value;
            Vector3 pointD = apexAtom.Point3D.Value;

            return(StereoTool.GetHandedness(pointA, pointB, pointC, pointD));
        }
Пример #4
0
        public void TetrahedralPlusAtomsAboveXYClockwiseTest()
        {
            // above the XY plane
            IAtom baseA = new Atom("C", new Vector3(0, 0, 1));
            IAtom baseB = new Atom("C", new Vector3(1, 0, 1));
            IAtom baseC = new Atom("C", new Vector3(1, 1, 1));

            IAtom           positiveApex = new Atom("C", new Vector3(0.5, 0.5, 2));
            TetrahedralSign tetSign      = StereoTool.GetHandedness(baseC, baseB, baseA, positiveApex);

            Assert.AreEqual(TetrahedralSign.Minus, tetSign);
        }
Пример #5
0
        public void TetrahedralMinusAtomsBelowXYTest()
        {
            // below the XY plane
            IAtom baseA = new Atom("C", new Vector3(0, 0, -1));
            IAtom baseB = new Atom("C", new Vector3(1, 0, -1));
            IAtom baseC = new Atom("C", new Vector3(1, 1, -1));

            IAtom           negativeApex = new Atom("C", new Vector3(0.5, 0.5, -2));
            TetrahedralSign tetSign      = StereoTool.GetHandedness(baseA, baseB, baseC, negativeApex);

            Assert.AreEqual(TetrahedralSign.Minus, tetSign);
        }
Пример #6
0
        /// <summary>
        /// Take four atoms, and return <see cref="TetrahedralStereo.Clockwise"/> or <see cref="TetrahedralStereo.AntiClockwise"/>.
        /// The first atom is the one pointing towards the observer.
        /// </summary>
        /// <param name="atom1">the atom pointing towards the observer</param>
        /// <param name="atom2">the second atom (points away)</param>
        /// <param name="atom3">the third atom (points away)</param>
        /// <param name="atom4">the fourth atom (points away)</param>
        /// <returns>clockwise or anticlockwise</returns>
        public static TetrahedralStereo GetStereo(IAtom atom1, IAtom atom2, IAtom atom3, IAtom atom4)
        {
            // a normal is calculated for the base atoms (2, 3, 4) and compared to
            // the first atom. PLUS indicates ACW.
            TetrahedralSign sign = StereoTool.GetHandedness(atom2, atom3, atom4, atom1);

            if (sign == TetrahedralSign.Plus)
            {
                return(TetrahedralStereo.AntiClockwise);
            }
            else
            {
                return(TetrahedralStereo.Clockwise);
            }
        }