---
url: /dyad/stable/stdlib/RotationalComponents/components/Components.RelativeStates.md
description: Dyad Components.RelativeStates docs.  Definition of relative state variables.
---

# `Components.RelativeStates` {#Components.RelativeStates}

Definition of relative state variables.

Usually, the absolute angle and the absolute angular velocity of `Inertia` models are used as state variables. In some circumstances, relative quantities are better suited, e.g., because it may be easier to supply initial values. In such cases, model `RelativeStates` allows the definition of state variables in the following way:

* Connect an instance of this model between two spline connectors.

* The **relative rotation angle** and the **relative angular velocity** between the two connectors are used as **state variables**.

This component transmits zero torque on both splines. Its only purpose is to introduce `phi_rel` and `w_rel` as preferred state variables via high `statePriority`.

This component extends from [`RotationalComponents.Interfaces.PartialTwoSplines`](../types/Interfaces.PartialTwoSplines.md)

## Usage {#Usage}

`RotationalComponents.Components.RelativeStates()`

## Connectors {#Connectors}

* `spline_a` - This connector represents a rotational spline with angle and torque as the potential and flow variables, respectively. ([`Spline`](/stdlib/Dyad/connectors/Spline#Spline))

* `spline_b` - This connector represents a rotational spline with angle and torque as the potential and flow variables, respectively. ([`Spline`](/stdlib/Dyad/connectors/Spline#Spline))

## Variables {#Variables}

|      Name |                                      Description |  Units |
| ---------:| ------------------------------------------------:| ------:|
| `phi_rel` |   Relative rotation angle used as state variable |    rad |
|   `w_rel` | Relative angular velocity used as state variable |  rad/s |
|   `a_rel` |                    Relative angular acceleration | rad/s2 |

## Behavior {#Behavior}

$$ \begin{align}
\mathtt{phi_rel}\left( t \right) &=  - \mathtt{spline_a.phi}\left( t \right) + \mathtt{spline_b.phi}\left( t \right) \\
\mathtt{w_rel}\left( t \right) &= \frac{\mathrm{d}\mathtt{phi_rel}\left( t \right)}{\mathrm{d}t} \\
\mathtt{a_rel}\left( t \right) &= \frac{\mathrm{d}\mathtt{w_rel}\left( t \right)}{\mathrm{d}t} \\
\mathtt{spline_a.tau}\left( t \right) &= 0 \\
\mathtt{spline_b.tau}\left( t \right) &= 0
\end{align}
$$

## Source {#Source}

```dyad
"""
Definition of relative state variables.

Usually, the absolute angle and the absolute angular velocity of
`Inertia` models are used as state variables. In some circumstances,
relative quantities are better suited, e.g., because it may be easier
to supply initial values. In such cases, model `RelativeStates` allows
the definition of state variables in the following way:

- Connect an instance of this model between two spline connectors.
- The **relative rotation angle** and the **relative angular velocity**
  between the two connectors are used as **state variables**.

This component transmits zero torque on both splines. Its only purpose is
to introduce `phi_rel` and `w_rel` as preferred state variables via high
`statePriority`.
"""
component RelativeStates
  extends RotationalComponents.Interfaces.PartialTwoSplines
  "Relative rotation angle used as state variable"
  variable phi_rel::Angle(statePriority = 50)
  "Relative angular velocity used as state variable"
  variable w_rel::AngularVelocity(statePriority = 50)
  "Relative angular acceleration"
  variable a_rel::AngularAcceleration
relations
  phi_rel = spline_b.phi - spline_a.phi
  w_rel = der(phi_rel)
  a_rel = der(w_rel)
  spline_a.tau = 0
  spline_b.tau = 0
metadata {
  "Dyad": {
    "icons": {"default": "dyad://RotationalComponents/RelativeStates.svg"},
    "labels": [{"label": "$(instance)", "layer": "icon", "x": 500, "y": 901, "rot": 0}]
  }
}
end
```

```dyad
"""
Definition of relative state variables.

Usually, the absolute angle and the absolute angular velocity of
`Inertia` models are used as state variables. In some circumstances,
relative quantities are better suited, e.g., because it may be easier
to supply initial values. In such cases, model `RelativeStates` allows
the definition of state variables in the following way:

- Connect an instance of this model between two spline connectors.
- The **relative rotation angle** and the **relative angular velocity**
  between the two connectors are used as **state variables**.

This component transmits zero torque on both splines. Its only purpose is
to introduce `phi_rel` and `w_rel` as preferred state variables via high
`statePriority`.
"""
component RelativeStates
  "First spline"
  spline_a = Spline() {"Dyad": {"placement": {"icon": {"x1": -50, "y1": 450, "x2": 50, "y2": 550}}}}
  "Second spline"
  spline_b = Spline() {"Dyad": {"placement": {"icon": {"x1": 950, "y1": 450, "x2": 1050, "y2": 550}}}}
  "Relative rotation angle used as state variable"
  variable phi_rel::Angle(statePriority = 50)
  "Relative angular velocity used as state variable"
  variable w_rel::AngularVelocity(statePriority = 50)
  "Relative angular acceleration"
  variable a_rel::AngularAcceleration
relations
  phi_rel = spline_b.phi - spline_a.phi
  w_rel = der(phi_rel)
  a_rel = der(w_rel)
  spline_a.tau = 0
  spline_b.tau = 0
metadata {
  "Dyad": {
    "icons": {"default": "dyad://RotationalComponents/RelativeStates.svg"},
    "labels": [{"label": "$(instance)", "layer": "icon", "x": 500, "y": 901, "rot": 0}]
  }
}
end
```

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses
