# to_zmat¶

`Cartesian.``to_zmat`(buildlist=None, fragment_list=None, check_linearity=True)[source]

Transform to internal coordinates.

Transforming to internal coordinates involves basically three
steps:
1. Define an order of how to build.
2. Check for problematic local linearity. In this algorithm an
angle with `170 < angle < 10` is assumed to be linear. This is not the mathematical definition, but makes it safer against “floating point noise”
3. Calculate the bond lengths, angles and dihedrals using the
references defined in step 1 and 2.

In the first two steps a so called `buildlist` is created. This is basically a `np.array` of shape `(n_atoms, 4)` and

integer type.
The four columns are ``[‘own_index’, ‘bond_with’, ‘angle_with’,
‘dihedral_with’]``.
This means that usually the upper right triangle can be any
number, because for example the first atom has no other atom as reference.
It is important to know, that getting the buildlist is a very
costly step since the algoritym tries to make some guesses based on the connectivity to create a “chemical” zmatrix.
If you create several zmatrices based on the same references
you can save the buildlist of a zmatrix with `Zmat.build_list()`.
If you then pass the buildlist as argument to `to_zmat`,
then the algorithm directly starts with step 3.

Another thing is that you can specify fragments. For this purpose the function `Cartesian.get_fragment()`

is quite handy.

An element of fragment_list looks like:

```(fragment, connections)
```
Fragment is a `Cartesian` instance and connections is a
`(3, 4)` numpy integer array, that defines how the fragment is connected to the molecule.
Parameters: buildlist (np.array) – fragment_list (list) – check_linearity (bool) – A new instance of `Zmat`. Zmat