PharmacophoreAngleBond extends Bond { public double getBondLength() { double epsilon = 1e-3; PharmacophoreAtom atom1 = (PharmacophoreAtom) getAtom(0); PharmacophoreAtom atom2 = (PharmacophoreAtom) getAtom(1); PharmacophoreAtom atom3 = (PharmacophoreAtom) getAtom(2); double a2 = atom3.getPoint3d().distanceSquared(atom1.getPoint3d()); double b2 = atom3.getPoint3d().distanceSquared(atom2.getPoint3d()); double c2 = atom2.getPoint3d().distanceSquared(atom1.getPoint3d()); double cosangle = (b2 + c2 - a2) / (2 * Math.sqrt(b2) * Math.sqrt(c2)); if (-1.0 - epsilon < cosangle && -1.0 + epsilon > cosangle) return 180.0; if (1.0 - epsilon < cosangle && 1.0 + epsilon > cosangle) return 0.0; return Math.acos(cosangle) * 180.0 / Math.PI; } PharmacophoreAngleBond(PharmacophoreAtom patom1, PharmacophoreAtom patom2, PharmacophoreAtom patom3); double getBondLength();  }
@Test public void testGetAngle1() { PharmacophoreAtom patom1 = new PharmacophoreAtom("[CX2]N", "Amine", new Point3d(0, 0, 0)); PharmacophoreAtom patom2 = new PharmacophoreAtom("c1ccccc1", "Aromatic", new Point3d(1, 1, 1)); PharmacophoreAtom patom3 = new PharmacophoreAtom("C", "Blah", new Point3d(2, 2, 2)); PharmacophoreAngleBond pbond = new PharmacophoreAngleBond(patom1, patom2, patom3); Assert.assertEquals(180, pbond.getBondLength(), 0.00001); }
@Test public void testGetAngle2() { PharmacophoreAtom patom1 = new PharmacophoreAtom("[CX2]N", "Amine", new Point3d(0, 0, 0)); PharmacophoreAtom patom2 = new PharmacophoreAtom("c1ccccc1", "Aromatic", new Point3d(1, 1, 1)); PharmacophoreAtom patom3 = new PharmacophoreAtom("C", "Blah", new Point3d(0, 0, 0)); PharmacophoreAngleBond pbond = new PharmacophoreAngleBond(patom1, patom2, patom3); Assert.assertEquals(0, pbond.getBondLength(), 0.00001); }
@Test public void testGetAngle3() { PharmacophoreAtom patom1 = new PharmacophoreAtom("[CX2]N", "Amine", new Point3d(0, 1, 0)); PharmacophoreAtom patom2 = new PharmacophoreAtom("c1ccccc1", "Aromatic", new Point3d(0, 0, 0)); PharmacophoreAtom patom3 = new PharmacophoreAtom("C", "Blah", new Point3d(1, 0, 0)); PharmacophoreAngleBond pbond = new PharmacophoreAngleBond(patom1, patom2, patom3); Assert.assertEquals(90.0, pbond.getBondLength(), 0.00001); }
@Test public void testGetAngle4() { PharmacophoreAtom patom1 = new PharmacophoreAtom("[CX2]N", "Amine", new Point3d(1, 1, 0)); PharmacophoreAtom patom2 = new PharmacophoreAtom("c1ccccc1", "Aromatic", new Point3d(0, 0, 0)); PharmacophoreAtom patom3 = new PharmacophoreAtom("C", "Blah", new Point3d(1, 0, 0)); PharmacophoreAngleBond pbond = new PharmacophoreAngleBond(patom1, patom2, patom3); Assert.assertEquals(45.0, pbond.getBondLength(), 0.00001); }
@Test public void testGetAngle5() { PharmacophoreAtom patom1 = new PharmacophoreAtom("[CX2]N", "Amine", new Point3d(1, 1, 1)); PharmacophoreAtom patom2 = new PharmacophoreAtom("c1ccccc1", "Aromatic", new Point3d(0, 0, 0)); PharmacophoreAtom patom3 = new PharmacophoreAtom("C", "Blah", new Point3d(1, 0, 0)); PharmacophoreAngleBond pbond = new PharmacophoreAngleBond(patom1, patom2, patom3); Assert.assertEquals(54.7356, pbond.getBondLength(), 0.0001); }