# Spatial Contraints

It is common to ask for the spatial relationship or extrinsics between two
components. A Plex incorporates this information in the form of *spatial
constraints*. A spatial constraint can be broken down as:

Field | Type |
Description |
---|---|---|

Extrinsics | `Extrinsics` |
The extrinsics describing the "To" from "From" transformation. |

Covariance | `ExtrinsicCovariance` |
The covariance of the extrinsics described by this constraint. |

From | `Uuid` |
The UUID of the component that describes the "From" or base coordinate frame. |

To | `Uuid` |
The UUID of the component that describes the "To" coordinate frame, which we are transforming into. This can be considered the "origin" of the extrinsics matrix |

## Extrinsics, "From", and "To"

**tl;dr**: the reference frame for the extrinsics transform is in the coordinate frame of the "to"
component. It would move points from the coordinate frame of the "from" component.

Our extrinsics type is essentially a way to describe how to transform points in one coordinate
system into another. Anyone who has ever worked with transforms has experienced confusion in
convention. In order to cut through the ambiguity of extrinsics, every spatial constraint has a
`from`

and `to`

field. Let's dive into how this works.

We can think of an extrinsics transform between components \(A\) and \(B\) using the following notation:

If we wanted to move a point \(p\) from the frame of reference of component \(B\) to that of \(A\), we would use the following math:

...also read as "\(p_A\) equals \(p_B\) to \(A\) from \(B\)".

Thus, when constructing a spatial constraint, **the reference frame for the extrinsics transform is
in the coordinate frame of component \(A\)**, and would move points from the coordinate frame of
component \(B\). In code, this would look like:

```
let to: component_A_uuid
let from: component_B_uuid
```

Both `from`

and `to`

must reference components within the Plex.

## Spatial Covariance

Spatial covariance is generally presented as a 6×6 matrix relating the variance-covariance of an se3 lie group:

When traversing for spatial constraints within the Plex, the constraint returned
will always contain the extrinsic with the *minimum overall covariance*. This
ensures that users will always get the extrinsic that has the smallest
covariance (thus, the highest confidence / precision), even if multiple spatial
constraints exist between any two components.