/** * 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)); } } } }
writeVector3d(crystal.getA()); writeVector3d(crystal.getB()); writeVector3d(crystal.getC());
Assert.assertEquals("Fm3m", crystal.getSpaceGroup()); Assert.assertEquals(2, crystal.getAtomCount()); Vector3d aaxis = crystal.getA(); Assert.assertEquals(4.5, aaxis.x, 0.1); Assert.assertEquals(0.0, aaxis.y, 0.1);
writeln("TITL Produced with CDK (http://cdk.sf.net/)"); Vector3d a = crystal.getA(); Vector3d b = crystal.getB(); Vector3d c = crystal.getC();
@Test public void testClone_Axes() throws Exception { ICrystal crystal1 = (ICrystal) newChemObject(); Vector3d axes = new Vector3d(1.0, 2.0, 3.0); crystal1.setA(axes); ICrystal crystal2 = (ICrystal) crystal1.clone(); // test cloning of axes crystal1.getA().x = 5.0; Assert.assertEquals(1.0, crystal2.getA().x, 0.001); }
Assert.assertEquals("Fm3m", crystal.getSpaceGroup()); Assert.assertEquals(2, crystal.getAtomCount()); Vector3d aaxis = crystal.getA(); Assert.assertEquals(4.5, aaxis.x, 0.1); Assert.assertEquals(0.0, aaxis.y, 0.1);
Vector3d a = crystal.getA(); Assert.assertEquals(7.971030, a.x, 0.000001); Assert.assertEquals(0.0, a.y, 0.000001);
Vector3d a = crystal.getA(); Vector3d b = crystal.getB(); Vector3d c = crystal.getC();
Assert.assertTrue(GeometryUtil.has3DCoordinates(crystal)); Vector3d a = crystal.getA(); Assert.assertTrue(a.x != 0.0); Vector3d b = crystal.getB();
public void writeCrystal(ICrystal crystal) throws CDKException { try { writeHeader(); Vector3d a = crystal.getA(); Vector3d b = crystal.getB(); Vector3d c = crystal.getC();
public void writeCrystal(ICrystal crystal) throws CDKException { try { writeHeader(); Vector3d a = crystal.getA(); Vector3d b = crystal.getB(); Vector3d c = crystal.getC();
crystal.setC(axis); logger.debug("Crystal: ", crystal); a = crystal.getA(); b = crystal.getB(); c = crystal.getC();
@Test public void testGetA() { ICrystal crystal = (ICrystal) newChemObject(); crystal.setA(new Vector3d(1.0, 2.0, 3.0)); Vector3d a = crystal.getA(); Assert.assertNotNull(a); }
@Test public void testSetZeroAxes() { ICrystal crystal = (ICrystal) newChemObject(); crystal.setA(new Vector3d(1.0, 2.0, 3.0)); Vector3d a = crystal.getA(); Assert.assertNotNull(a); }
@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; }
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 testSetA_Vector3d() { ICrystal crystal = (ICrystal) newChemObject(); crystal.setA(new Vector3d(1.0, 2.0, 3.0)); Vector3d a = crystal.getA(); Assert.assertEquals(1.0, a.x, 0.001); Assert.assertEquals(2.0, a.y, 0.001); Assert.assertEquals(3.0, a.z, 0.001); }
Assert.assertEquals(crystal.getA().x, rCrystal.getA().x, 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);