# skbot.transform¶

Manage n-dimensional coordinate transformations via directed graphs.

`skbot.transform` allows you to change the representation of a vector from one coordinate system to another, i.e., it transforms the basis of the vector. Contrary to similar libraries, this is not limited to 3D or affine transformations, but can transform in N dimensions and between different dimensions, too. Additionally, you can create chains - more precisely directed graphs - of transformations between different frames, which allows you to express quite complicated transformations.

If you come from a robotics background, this module is analogous to ROS tf2, but works in (and between) n-dimensions. This means it naturally includes projections, e.g. world space to pixel space, and it allows you to use more esoteric transformations like spherical coordinates, too.

## Examples¶

```>>> import skbot.transform as tf
>>> import numpy as np
```

Forward kinematics on a 1 DoF robot arm in 2D

```>>> # setup of the arm
>>> joint = tf.Rotation((1, 0), (0, 1))
>>> tool_frame = tf.Frame(2)
>>> world = joint(joint_frame)
>>> joint.angle = 0
>>> # FK of initial position
>>> tool_pos = tool_frame.transform((0, 0), to_frame=world)
>>> assert np.allclose(tool_pos, (1, 0))
>>> # Set new joint angle and compute new FK
>>> joint.angle = np.pi / 2
>>> tool_pos = tool_frame.transform((0, 0), to_frame=world)
>>> assert np.allclose(tool_pos, (0, 1))
```

## Base Elements¶

 `Frame`(ndim, *[, name]) Representation of a coordinate system. `Link`(parent_dim, child_dim) A directional relationship between two Frames

## Available Transformations¶

 `AffineSpace`(ndim, *[, axis]) Transform to affine space `Translation`(direction, *[, amount, axis]) Translation in N-D. `Rotation`(u, v, *[, axis]) Planar rotation in N-D. `PerspectiveProjection`(directions, amounts, *) Perspective projection in N-D.

 `EulerRotation`(sequence, angles, *[, ...]) Rotation based on Euler angles in 3D. `QuaternionRotation`(quaternion, *[, ...]) Rotation based on Quaternions in 3D. `RotvecRotation`(rotvec, *[, angle, degrees, axis]) Rotation based on rotation vector in 3D. `FrustumProjection`(hfov, image_shape) Frustum based intrinsic camera transformation. `RotationalJoint`(rotvec, *[, angle, degrees, ...]) Rotation with constraints in 3D. `PrismaticJoint`(direction, *[, upper_limit, ...]) Translation with constraints in N-D.

 `Rotation2D`(angle, *[, degrees, axis]) Rotation in 2D. `AngleJoint`(*[, angle, degrees, axis, ...]) Rotation with constraints in 2D. `AxialHexagonTransform`(*[, size, flat_top, axis]) Conversion to Axial Hexagon Coordininates in 2D `HexagonAxisRound`(*[, axis]) Round Hexagon Axis Coordinates in 2D.

 `CustomLink`(parent_dim, child_dim, transformation) A link representing a custom transformation. `CompundLink`(wrapped_links) A link representing a sequence of other links `InvertLink`(link) Inverse of an existing Link.

## Joints¶

Joints are a special subclass of links. On top of normal links, they are bounded, i.e. they have an `upper_limit` and a `lower_limit`, and their value can be accessed by the common name `param`. For example:

```import skbot.transform as tf
import numpy as np

joint = tf.AngleJoint()
assert joint.param == joint.angle
assert joint.lower_limit == 0
assert joint.upper_limit == 2 * np.pi

# setting param affects the angle
joint.param = np.pi
assert joint.angle == np.pi
```

Available Joints

 `RotationalJoint`(rotvec, *[, angle, degrees, ...]) Rotation with constraints in 3D. `PrismaticJoint`(direction, *[, upper_limit, ...]) Translation with constraints in N-D. `AngleJoint`(*[, angle, degrees, axis, ...]) Rotation with constraints in 2D.

Custom Joints

You can create your own joints by inheriting from `tf.Link` (to make the class a link) and from `tf.Joint` (to mark the class as a joint):

```class CustomJoint(tf.Link, tf.Joint):
...

# Make sure to implement the required properties:
# param, lower_limit, upper_limit
# and to implement a setter for param
```

## Functions¶

 `simplify_links`(links, *[, keep_links, ...]) Simplify a transformation sequence.