# Source code for skbot.transform.simplfy

```from typing import List
from .affine import AffineCompound, Translation, Rotation
from .joints import Joint
import numpy as np

*,
keep_joints: bool = False,
eps: float = 1e-16
"""Simplify a transformation sequence.

.. currentmodule:: skbot.transform

This function attempts to optimize the given transformation sequence by
reducing the number of transformations involved. For this it may replace or
modify any link in the sequence with the exception of those listed in
``keep_links``. Concretely it does the following modifications:

- It replaces double inversions with the original link.
- It drops 0 degree :class:`Rotations <Rotation>` (identities).
- It drops 0 amount :class:`Translations <Translation>` (identities).
- It combines series of translations into a single translation.
- It sorts translations before rotations.

Parameters
----------
The list of links to simplify.
A list list of links that - if present - should not be simplified.
keep_joints : bool
If True treat tf.Joint instances as if they were in keep_links.
eps : float
The number below which angles and translations are interpreted as 0.
Defaults to ``1e-16``.

Returns
-------
A new list of links that is a simplified version of the initial list.
"""

# skip if link should not be modified
continue

# resolve inversions

# still don't touch keep links
):
continue

# double inverse
continue

continue

# inverted translation
resolved = Translation(
)
continue

# inverted rotation
resolved = Rotation(
)
resolved.angle = -angle
continue

continue

# drop identity translations
continue

# drop identity rotations
continue

# no improvements for this link

idx = 0

idx += 1
continue

translations: List[Translation] = list()
break

idx += len(translations)

repeat = True
while repeat:
repeat = False
for idx in range(len(improved_links) - 1):

repeat = True
continue

subchains.append(current_subchain)
current_subchain = list()
else:
subchains.append(current_subchain)