/** * Creates Cartesian coordinates for all Atoms in the Crystal. */ public static void fractionalToCartesian(ICrystal crystal) { Iterator<IAtom> atoms = crystal.atoms().iterator(); Vector3d aAxis = crystal.getA(); Vector3d bAxis = crystal.getB(); Vector3d cAxis = crystal.getC(); while (atoms.hasNext()) { IAtom atom = atoms.next(); Point3d fracPoint = atom.getFractionalPoint3d(); if (fracPoint != null) { atom.setPoint3d(fractionalToCartesian(aAxis, bAxis, cAxis, fracPoint)); } } } }
Vector3d b = crystal.getB(); Vector3d c = crystal.getC(); frac = CrystalGeometryTools.cartesianToFractional(a, b, c, real);
@Test public void testGetB() { ICrystal crystal = (ICrystal) newChemObject(); crystal.setB(new Vector3d(1.0, 2.0, 3.0)); Vector3d a = crystal.getB(); Assert.assertNotNull(a); }
writeHeader(); Vector3d a = crystal.getA(); Vector3d b = crystal.getB(); Vector3d c = crystal.getC(); double[] ucParams = CrystalGeometryTools.cartesianToNotional(a, b, c);
logger.debug("Crystal: ", crystal); a = crystal.getA(); b = crystal.getB(); c = crystal.getC();
writeHeader(); Vector3d a = crystal.getA(); Vector3d b = crystal.getB(); Vector3d c = crystal.getC(); double[] ucParams = CrystalGeometryTools.cartesianToNotional(a, b, c);
Assert.assertEquals(0.0, aaxis.y, 0.1); Assert.assertEquals(0.0, aaxis.z, 0.1); Vector3d baxis = crystal.getB(); Assert.assertEquals(0.0, baxis.x, 0.1); Assert.assertEquals(4.5, baxis.y, 0.1);
Vector3d b = crystal.getB(); Vector3d c = crystal.getC(); frac = CrystalGeometryTools.cartesianToFractional(a, b, c, real);
Assert.assertEquals(0.0, aaxis.y, 0.1); Assert.assertEquals(0.0, aaxis.z, 0.1); Vector3d baxis = crystal.getB(); Assert.assertEquals(0.0, baxis.x, 0.1); Assert.assertEquals(4.5, baxis.y, 0.1);
writeVector3d(crystal.getB()); writeVector3d(crystal.getC());
@Test() public void cod1100784CellLengths() throws IOException, CDKException { InputStream in = getClass().getResourceAsStream("1100784.cif"); CIFReader cifReader = new CIFReader(in); IChemFile chemFile = cifReader.read(new ChemFile()); ICrystal crystal = chemFile.getChemSequence(0).getChemModel(0).getCrystal(); Assert.assertTrue( java.lang.Math.abs(crystal.getA().length() - 10.9754) < 1E-5 ); Assert.assertTrue( java.lang.Math.abs(crystal.getB().length() - 11.4045) < 1E-5 ); Assert.assertTrue( java.lang.Math.abs(crystal.getC().length() - 12.9314) < 1E-5 ); cifReader.close(); }
private CMLMolecule cdkCrystalToCMLMolecule(ICrystal crystal, boolean setIDs) { CMLMolecule molecule = cdkAtomContainerToCMLMolecule(crystal, false, false); CMLCrystal cmlCrystal = new CMLCrystal(); if (useCMLIDs && setIDs) { IDCreator.createIDs(crystal); } if (crystal.getID() != null && !crystal.getID().equals("")) cmlCrystal.setId(crystal.getID()); this.checkPrefix(cmlCrystal); cmlCrystal.setZ(crystal.getZ()); double[] params = CrystalGeometryTools.cartesianToNotional(crystal.getA(), crystal.getB(), crystal.getC()); logger.debug("Number of cell params: ", params.length); cmlCrystal.setCellParameters(params); molecule.appendChild(cmlCrystal); return molecule; }
Vector3d b = crystal.getB(); Vector3d c = crystal.getC(); double alength = a.length();
private CMLMolecule cdkCrystalToCMLMolecule(ICrystal crystal, boolean setIDs) { CMLMolecule molecule = cdkAtomContainerToCMLMolecule(crystal, false, false); CMLCrystal cmlCrystal = new CMLCrystal(); if (useCMLIDs && setIDs) { IDCreator.createIDs(crystal); } if (crystal.getID() != null && !crystal.getID().equals("")) cmlCrystal.setId(crystal.getID()); this.checkPrefix(cmlCrystal); cmlCrystal.setZ(crystal.getZ()); double[] params = CrystalGeometryTools.cartesianToNotional(crystal.getA(), crystal.getB(), crystal.getC()); logger.debug("Number of cell params: ", params.length); cmlCrystal.setCellParameters(params); molecule.appendChild(cmlCrystal); return molecule; }
@Test() public void cod1100784CellAngles() throws IOException, CDKException { InputStream in = getClass().getResourceAsStream("1100784.cif"); CIFReader cifReader = new CIFReader(in); IChemFile chemFile = cifReader.read(new ChemFile()); ICrystal crystal = chemFile.getChemSequence(0).getChemModel(0).getCrystal(); Vector3d a = crystal.getA(); Vector3d b = crystal.getB(); Vector3d c = crystal.getC(); double alpha = java.lang.Math.acos(b.dot(c)/(b.length()*c.length()))*180/java.lang.Math.PI; double beta = java.lang.Math.acos(c.dot(a)/(c.length()*a.length()))*180/java.lang.Math.PI; double gamma = java.lang.Math.acos(a.dot(b)/(a.length()*b.length()))*180/java.lang.Math.PI; Assert.assertTrue( java.lang.Math.abs(alpha - 109.1080) < 1E-5 ); Assert.assertTrue( java.lang.Math.abs(beta - 98.4090) < 1E-5 ); Assert.assertTrue( java.lang.Math.abs(gamma - 102.7470) < 1E-5 ); cifReader.close(); }
@Test public void testSetB_Vector3d() { ICrystal crystal = (ICrystal) newChemObject(); crystal.setB(new Vector3d(1.0, 2.0, 3.0)); Vector3d b = crystal.getB(); Assert.assertEquals(1.0, b.x, 0.001); Assert.assertEquals(2.0, b.y, 0.001); Assert.assertEquals(3.0, b.z, 0.001); }
Assert.assertEquals(crystal.getA().y, rCrystal.getA().y, 0.001); Assert.assertEquals(crystal.getA().z, rCrystal.getA().z, 0.001); Assert.assertEquals(crystal.getB().x, rCrystal.getB().x, 0.001); Assert.assertEquals(crystal.getB().y, rCrystal.getB().y, 0.001); Assert.assertEquals(crystal.getB().z, rCrystal.getB().z, 0.001); Assert.assertEquals(crystal.getC().x, rCrystal.getC().x, 0.001); Assert.assertEquals(crystal.getC().y, rCrystal.getC().y, 0.001);
Vector3d b = crystal.getB(); Assert.assertTrue(b.y != 0.0); Vector3d c = crystal.getC();
Assert.assertEquals(0.0, a.y, 0.000001); Assert.assertEquals(0.0, a.z, 0.000001); Vector3d b = crystal.getB(); Assert.assertEquals(0.0, b.x, 0.000001); Assert.assertEquals(18.772200, b.y, 0.000001);