def cart_to_zmat(self, coordinates):
N = len(self.graph.numbers)<EOL>if coordinates.shape != (N, <NUM_LIT:3>):<EOL><INDENT>raise ValueError("<STR_LIT>" % N)<EOL><DEDENT>result = np.zeros(N, dtype=self.dtype)<EOL>for i in range(N):<EOL><INDENT>ref0 = self.old_index[i]<EOL>rel1 = -<NUM_LIT:1><EOL>rel2 = -<NUM_LIT:1><EOL>rel3 = -<NUM_LIT:1><EOL>distance = <NUM_LIT:0><EOL>angle = <NUM_LIT:0><EOL>dihed = <NUM_LIT:0><EOL>if i > <NUM_LIT:0>:<EOL><INDENT>ref1 = self._get_new_ref([ref0])<EOL>distance = np.linalg.norm(coordinates[ref0]-coordinates[ref1])<EOL>rel1 = i - self.new_index[ref1]<EOL><DEDENT>if i > <NUM_LIT:1>:<EOL><INDENT>ref2 = self._get_new_ref([ref0, ref1])<EOL>angle, = ic.bend_angle(coordinates[[ref0, ref1, ref2]])<EOL>rel2 = i - self.new_index[ref2]<EOL><DEDENT>if i > <NUM_LIT:2>:<EOL><INDENT>ref3 = self._get_new_ref([ref0, ref1, ref2])<EOL>dihed, = ic.dihed_angle(coordinates[[ref0, ref1, ref2, ref3]])<EOL>rel3 = i - self.new_index[ref3]<EOL><DEDENT>result[i] = (self.graph.numbers[i], distance, rel1, angle, rel2, dihed, rel3)<EOL><DEDENT>return result<EOL>
Convert cartesian coordinates to ZMatrix format

           Argument:
             coordinates  --  Cartesian coordinates (numpy array Nx3)

           The coordinates must match with the graph that was used to initialize
           the ZMatrixGenerator object.