---
url: /dyad/stable/stdlib/MultibodyComponents/components/TransformRelativeVector.md
description: >-
  Dyad TransformRelativeVector docs.  Rotates a pure-rotation 3-vector between
  frames via a two-step rotation through the world frame: frame_r_in -> world ->
  frame_r_out.
---

# `TransformRelativeVector` {#TransformRelativeVector}

Rotates a pure-rotation 3-vector between frames via a two-step rotation through the world frame: `frame_r_in -> world -> frame_r_out`.

Same as `TransformAbsoluteVector`, but `frame_r_in`/`frame_r_out` may also resolve in `frame_b`, since two physical frames are available as orientation sources here.

## Usage {#Usage}

`MultibodyComponents.TransformRelativeVector()`

## Parameters: {#Parameters:}

|          Name |                      Description | Units |           Default value |
| -------------:| --------------------------------:| -----:| -----------------------:|
|  `frame_r_in` |  Frame in which r_in is resolved |     – | ResolveInFrame.FrameA() |
| `frame_r_out` | Frame in which r_out is resolved |     – | ResolveInFrame.FrameA() |

## Connectors {#Connectors}

* `frame_a` - Frame3D is the fundamental 3D connector used for 6DOF motion. Most components have one or several `Frame`

connectors that can be connected together ([`Frame3D`](/stdlib/Dyad/connectors/Frame3D#Frame3D))

* `frame_b` - Frame3D is the fundamental 3D connector used for 6DOF motion. Most components have one or several `Frame`

connectors that can be connected together ([`Frame3D`](/stdlib/Dyad/connectors/Frame3D#Frame3D))

* `frame_resolve` - Frame3D is the fundamental 3D connector used for 6DOF motion. Most components have one or several `Frame`

connectors that can be connected together ([`Frame3D`](/stdlib/Dyad/connectors/Frame3D#Frame3D))

* `r_in_x` - This connector represents a real signal as an input to a component ([`RealInput`](/stdlib/Dyad/connectors/RealInput#RealInput))

* `r_in_y` - This connector represents a real signal as an input to a component ([`RealInput`](/stdlib/Dyad/connectors/RealInput#RealInput))

* `r_in_z` - This connector represents a real signal as an input to a component ([`RealInput`](/stdlib/Dyad/connectors/RealInput#RealInput))

* `r_out_x` - This connector represents a real signal as an output from a component ([`RealOutput`](/stdlib/Dyad/connectors/RealOutput#RealOutput))

* `r_out_y` - This connector represents a real signal as an output from a component ([`RealOutput`](/stdlib/Dyad/connectors/RealOutput#RealOutput))

* `r_out_z` - This connector represents a real signal as an output from a component ([`RealOutput`](/stdlib/Dyad/connectors/RealOutput#RealOutput))

## Variables {#Variables}

|    Name |                                Description | Units |
| -------:| ------------------------------------------:| -----:|
|  `r_in` |                                            |     – |
|    `R1` | Rotation matrix from world into frame_r_in |     – |
| `r_out` |                                            |     – |

## Behavior {#Behavior}

$$ \begin{align}
\mathtt{frame_a.f}\_{1}\left( t \right) &= 0 \\
\mathtt{frame_a.f}\_{2}\left( t \right) &= 0 \\
\mathtt{frame_a.f}\_{3}\left( t \right) &= 0 \\
\mathtt{frame_a.tau}\_{1}\left( t \right) &= 0 \\
\mathtt{frame_a.tau}\_{2}\left( t \right) &= 0 \\
\mathtt{frame_a.tau}\_{3}\left( t \right) &= 0 \\
\mathtt{frame_b.f}\_{1}\left( t \right) &= 0 \\
\mathtt{frame_b.f}\_{2}\left( t \right) &= 0 \\
\mathtt{frame_b.f}\_{3}\left( t \right) &= 0 \\
\mathtt{frame_b.tau}\_{1}\left( t \right) &= 0 \\
\mathtt{frame_b.tau}\_{2}\left( t \right) &= 0 \\
\mathtt{frame_b.tau}\_{3}\left( t \right) &= 0 \\
\mathtt{r_out_x}\left( t \right) &= \mathtt{r_in_x}\left( t \right) \\
\mathtt{r_out_y}\left( t \right) &= \mathtt{r_in_y}\left( t \right) \\
\mathtt{r_out_z}\left( t \right) &= \mathtt{r_in_z}\left( t \right)
\end{align}
$$

## Source {#Source}

```dyad
"""
Rotates a pure-rotation 3-vector between frames via a two-step rotation
through the world frame: `frame_r_in -> world -> frame_r_out`.

Same as `TransformAbsoluteVector`, but `frame_r_in`/`frame_r_out` may also
resolve in `frame_b`, since two physical frames are available as orientation
sources here.
"""
component TransformRelativeVector
  frame_a = Frame3D() {
    "Dyad": {"placement": {"diagram": {"x1": 200, "y1": 950, "x2": 300, "y2": 1050}}}
  }
  frame_b = Frame3D() {
    "Dyad": {"placement": {"diagram": {"x1": 700, "y1": 950, "x2": 800, "y2": 1050}}}
  }
  frame_resolve = Frame3D() if case(frame_r_in, ResolveInFrame.FrameResolve) or case(frame_r_out, ResolveInFrame.FrameResolve) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": -50, "x2": 550, "y2": 50, "rot": 0}
      },
      "tags": []
    }
  }
  r_in_x = RealInput() {
    "Dyad": {"placement": {"diagram": {"x1": -50, "y1": 140, "x2": 50, "y2": 240}}}
  }
  r_in_y = RealInput() {
    "Dyad": {"placement": {"diagram": {"x1": -50, "y1": 450, "x2": 50, "y2": 550}}}
  }
  r_in_z = RealInput() {
    "Dyad": {"placement": {"diagram": {"x1": -50, "y1": 760, "x2": 50, "y2": 860}}}
  }
  r_out_x = RealOutput() {
    "Dyad": {"placement": {"diagram": {"x1": 1000, "y1": 140, "x2": 1100, "y2": 240}}}
  }
  r_out_y = RealOutput() {
    "Dyad": {"placement": {"diagram": {"x1": 1000, "y1": 450, "x2": 1100, "y2": 550}}}
  }
  r_out_z = RealOutput() {
    "Dyad": {"placement": {"diagram": {"x1": 1000, "y1": 760, "x2": 1100, "y2": 860}}}
  }
  "Frame in which r_in is resolved"
  structural parameter frame_r_in::ResolveInFrame = ResolveInFrame.FrameA()
  "Frame in which r_out is resolved"
  structural parameter frame_r_out::ResolveInFrame = ResolveInFrame.FrameA()
  variable r_in::Real[3] if frame_r_in != frame_r_out
  "Rotation matrix from world into frame_r_in"
  variable R1::Real[3, 3] if frame_r_in != frame_r_out
  variable r_out::Real[3] if frame_r_in != frame_r_out
relations
  frame_a.f = [0, 0, 0]
  frame_a.tau = [0, 0, 0]
  frame_b.f = [0, 0, 0]
  frame_b.tau = [0, 0, 0]
  if case(frame_r_in, ResolveInFrame.FrameResolve) or case(frame_r_out, ResolveInFrame.FrameResolve)
    frame_resolve.f = [0, 0, 0]
    frame_resolve.tau = [0, 0, 0]
  end
  if frame_r_in == frame_r_out
    r_out_x = r_in_x
    r_out_y = r_in_y
    r_out_z = r_in_z
  else
    r_in = [r_in_x, r_in_y, r_in_z]
    switch frame_r_in
      case World
        R1 = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
      case FrameA
        R1 = frame_a.R
      case FrameB
        R1 = frame_b.R
      case FrameResolve
        R1 = frame_resolve.R
    end
    switch frame_r_out
      case World
        r_out = resolve1(R1, r_in)
      case FrameA
        r_out = resolve_relative(r_in, R1, frame_a.R)
      case FrameB
        r_out = resolve_relative(r_in, R1, frame_b.R)
      case FrameResolve
        r_out = resolve_relative(r_in, R1, frame_resolve.R)
    end
    [r_out_x, r_out_y, r_out_z] = r_out
  end
metadata {
  "Dyad": {
    "icons": {"default": "dyad://MultibodyComponents/TwoFrameSensor.svg"},
    "labels": [{"label": "transform rel", "x": 500, "y": 680, "rot": 0}]
  }
}
end
```

```dyad
"""
Rotates a pure-rotation 3-vector between frames via a two-step rotation
through the world frame: `frame_r_in -> world -> frame_r_out`.

Same as `TransformAbsoluteVector`, but `frame_r_in`/`frame_r_out` may also
resolve in `frame_b`, since two physical frames are available as orientation
sources here.
"""
component TransformRelativeVector
  frame_a = Frame3D() {
    "Dyad": {"placement": {"diagram": {"x1": 200, "y1": 950, "x2": 300, "y2": 1050}}}
  }
  frame_b = Frame3D() {
    "Dyad": {"placement": {"diagram": {"x1": 700, "y1": 950, "x2": 800, "y2": 1050}}}
  }
  frame_resolve = Frame3D() if case(frame_r_in, ResolveInFrame.FrameResolve) or case(frame_r_out, ResolveInFrame.FrameResolve) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": -50, "x2": 550, "y2": 50, "rot": 0}
      },
      "tags": []
    }
  }
  r_in_x = RealInput() {
    "Dyad": {"placement": {"diagram": {"x1": -50, "y1": 140, "x2": 50, "y2": 240}}}
  }
  r_in_y = RealInput() {
    "Dyad": {"placement": {"diagram": {"x1": -50, "y1": 450, "x2": 50, "y2": 550}}}
  }
  r_in_z = RealInput() {
    "Dyad": {"placement": {"diagram": {"x1": -50, "y1": 760, "x2": 50, "y2": 860}}}
  }
  r_out_x = RealOutput() {
    "Dyad": {"placement": {"diagram": {"x1": 1000, "y1": 140, "x2": 1100, "y2": 240}}}
  }
  r_out_y = RealOutput() {
    "Dyad": {"placement": {"diagram": {"x1": 1000, "y1": 450, "x2": 1100, "y2": 550}}}
  }
  r_out_z = RealOutput() {
    "Dyad": {"placement": {"diagram": {"x1": 1000, "y1": 760, "x2": 1100, "y2": 860}}}
  }
  "Frame in which r_in is resolved"
  structural parameter frame_r_in::ResolveInFrame = ResolveInFrame.FrameA()
  "Frame in which r_out is resolved"
  structural parameter frame_r_out::ResolveInFrame = ResolveInFrame.FrameA()
  variable r_in::Real[3] if frame_r_in != frame_r_out
  "Rotation matrix from world into frame_r_in"
  variable R1::Real[3, 3] if frame_r_in != frame_r_out
  variable r_out::Real[3] if frame_r_in != frame_r_out
relations
  frame_a.f = [0, 0, 0]
  frame_a.tau = [0, 0, 0]
  frame_b.f = [0, 0, 0]
  frame_b.tau = [0, 0, 0]
  if case(frame_r_in, ResolveInFrame.FrameResolve) or case(frame_r_out, ResolveInFrame.FrameResolve)
    frame_resolve.f = [0, 0, 0]
    frame_resolve.tau = [0, 0, 0]
  end
  if frame_r_in == frame_r_out
    r_out_x = r_in_x
    r_out_y = r_in_y
    r_out_z = r_in_z
  else
    r_in = [r_in_x, r_in_y, r_in_z]
    switch frame_r_in
      case World
        R1 = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
      case FrameA
        R1 = frame_a.R
      case FrameB
        R1 = frame_b.R
      case FrameResolve
        R1 = frame_resolve.R
    end
    switch frame_r_out
      case World
        r_out = resolve1(R1, r_in)
      case FrameA
        r_out = resolve_relative(r_in, R1, frame_a.R)
      case FrameB
        r_out = resolve_relative(r_in, R1, frame_b.R)
      case FrameResolve
        r_out = resolve_relative(r_in, R1, frame_resolve.R)
    end
    [r_out_x, r_out_y, r_out_z] = r_out
  end
metadata {
  "Dyad": {
    "icons": {"default": "dyad://MultibodyComponents/TwoFrameSensor.svg"},
    "labels": [{"label": "transform rel", "x": 500, "y": 680, "rot": 0}]
  }
}
end
```

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses
