test_class.file: storage/io/src/test/java/org/openscience/cdk/geometry/ZMatrixToolsTest.java
test_class.identifier: ZMatrixToolsTest
test_class.superclass: extends CDKTestCase
test_case.body: @Test
      public void testZmatrixToCartesian_arraydouble_arrayint_arraydouble_arrayint_arraydouble_arrayint() {
          // acetaldehyde example from http://www.shodor.org/chemviz/zmatrices/babelex.html
          int[] first_atoms = {0, 0, 0, 0, 3, 3, 3};
          double[] distances = {0, 1.2, 1.1, 1.5, 1.1, 1.1, 1.1};
          int[] second_atoms = {0, 0, 1, 1, 0, 0, 0};
          double[] angles = {0, 0, 120, 120, 110, 110, 110};
          int[] third_atoms = {0, 0, 0, 2, 1, 1, 1};
          double[] dihedrals = {0, 0, 0, 180, 0, 120, -120};
          Point3d points[] = ZMatrixTools.zmatrixToCartesian(distances, first_atoms, angles, second_atoms, dihedrals,
                  third_atoms);
          Assert.assertEquals(-0.5500, points[2].x, 0.0001);
          Assert.assertEquals(-1.3664, points[5].y, 0.0001);
          Assert.assertEquals(-0.8952, points[6].z, 0.0001);
      }
test_case.class_method_signature: ZMatrixToolsTest.testZmatrixToCartesian_arraydouble_arrayint_arraydouble_arrayint_arraydouble_arrayint()
test_case.full_signature: @Test public void testZmatrixToCartesian_arraydouble_arrayint_arraydouble_arrayint_arraydouble_arrayint()
test_case.identifier: testZmatrixToCartesian_arraydouble_arrayint_arraydouble_arrayint_arraydouble_arrayint
test_case.invocations: zmatrixToCartesian assertEquals assertEquals assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testZmatrixToCartesian_arraydouble_arrayint_arraydouble_arrayint_arraydouble_arrayint()
focal_class.file: storage/io/src/main/java/org/openscience/cdk/geometry/ZMatrixTools.java
focal_class.identifier: ZMatrixTools
focal_class.class_method_signature: ZMatrixTools.zmatrixToCartesian(double[] distances, int[] first_atoms, double[] angles,
              int[] second_atoms, double[] dihedrals, int[] third_atoms)
focal_class.full_signature: public static Point3d[] zmatrixToCartesian(double[] distances, int[] first_atoms, double[] angles,
              int[] second_atoms, double[] dihedrals, int[] third_atoms)
focal_class.identifier: zmatrixToCartesian
focal_class.modifiers: public static
focal_class.parameters: (double[] distances, int[] first_atoms, double[] angles,
              int[] second_atoms, double[] dihedrals, int[] third_atoms)
focal_class.return: Point3d[]
focal_class.signature: Point3d[] zmatrixToCartesian(double[] distances, int[] first_atoms, double[] angles,
              int[] second_atoms, double[] dihedrals, int[] third_atoms)
focal_class.class_method_signature: ZMatrixTools.rotate(Vector3d vector, Vector3d axis, double angle)
focal_class.full_signature: private static Vector3d rotate(Vector3d vector, Vector3d axis, double angle)
focal_class.identifier: rotate
focal_class.modifiers: private static
focal_class.parameters: (Vector3d vector, Vector3d axis, double angle)
focal_class.return: Vector3d
focal_class.signature: Vector3d rotate(Vector3d vector, Vector3d axis, double angle)
focal_method.body: public static Point3d[] zmatrixToCartesian(double[] distances, int[] first_atoms, double[] angles,
              int[] second_atoms, double[] dihedrals, int[] third_atoms) {
          Point3d[] cartesianCoords = new Point3d[distances.length];
          for (int index = 0; index < distances.length; index++) {
              if (index == 0) {
                  cartesianCoords[index] = new Point3d(0d, 0d, 0d);
              } else if (index == 1) {
                  cartesianCoords[index] = new Point3d(distances[1], 0d, 0d);
              } else if (index == 2) {
                  cartesianCoords[index] = new Point3d(-Math.cos((angles[2] / 180) * Math.PI) * distances[2]
                          + distances[1], Math.sin((angles[2] / 180) * Math.PI) * distances[2], 0d);
                  if (first_atoms[index] == 0) cartesianCoords[index].x = (cartesianCoords[index].x - distances[1]) * -1;
              } else {
                  Vector3d cd = new Vector3d();
                  cd.sub(cartesianCoords[third_atoms[index]], cartesianCoords[second_atoms[index]]);
  
                  Vector3d bc = new Vector3d();
                  bc.sub(cartesianCoords[second_atoms[index]], cartesianCoords[first_atoms[index]]);
  
                  Vector3d n1 = new Vector3d();
                  n1.cross(cd, bc);
  
                  Vector3d n2 = rotate(n1, bc, -dihedrals[index]);
                  Vector3d ba = rotate(bc, n2, -angles[index]);
  
                  ba.normalize();
                  ba.scale(distances[index]);
  
                  Point3d result = new Point3d();
                  result.add(cartesianCoords[first_atoms[index]], ba);
                  cartesianCoords[index] = result;
              }
          }
          return cartesianCoords;
      }
focal_method.class_method_signature: ZMatrixTools.zmatrixToCartesian(double[] distances, int[] first_atoms, double[] angles,
              int[] second_atoms, double[] dihedrals, int[] third_atoms)
focal_method.full_signature: public static Point3d[] zmatrixToCartesian(double[] distances, int[] first_atoms, double[] angles,
              int[] second_atoms, double[] dihedrals, int[] third_atoms)
focal_method.identifier: zmatrixToCartesian
focal_method.invocations: cos sin sub sub cross rotate rotate normalize scale add
focal_method.modifiers: public static
focal_method.parameters: (double[] distances, int[] first_atoms, double[] angles,
              int[] second_atoms, double[] dihedrals, int[] third_atoms)
focal_method.return: Point3d[]
focal_method.signature: Point3d[] zmatrixToCartesian(double[] distances, int[] first_atoms, double[] angles,
              int[] second_atoms, double[] dihedrals, int[] third_atoms)