---
url: /dyad/dev/stdlib/MultibodyComponents/components/RelativeAngles.md
description: >-
  Dyad RelativeAngles docs.  Measures relative Euler/Cardan angles between two
  frames.
---

# `RelativeAngles` {#RelativeAngles}

Measures relative Euler/Cardan angles between two frames.

Computes the three rotation angles to rotate `frame_a` into `frame_b` for the given axis `sequence` (default: \[1,2,3] = XYZ). This is a sensor: no forces or torques are exerted.

## Usage {#Usage}

`MultibodyComponents.RelativeAngles()`

## Parameters: {#Parameters:}

|       Name | Description | Units | Default value |
| ----------:| -----------:| -----:| -------------:|
| `sequence` |             |     – |     \[1, 2, 3] |

## 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))

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

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

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

## Variables {#Variables}

|     Name | Description | Units |
| --------:| -----------:| -----:|
|  `R_rel` |             |     – |
| `angles` |             |   rad |

## Behavior {#Behavior}

## Source {#Source}

```dyad
"""
Measures relative Euler/Cardan angles between two frames.

Computes the three rotation angles to rotate `frame_a` into `frame_b`
for the given axis `sequence` (default: [1,2,3] = XYZ).
This is a sensor: no forces or torques are exerted.
"""
component RelativeAngles
  frame_a = Frame3D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -50, "y1": 450, "x2": 50, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  frame_b = Frame3D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 950, "y1": 450, "x2": 1050, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  structural parameter sequence::Integer[3] = [1, 2, 3]
  angle_1 = RealOutput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 130, "y1": 970, "x2": 230, "y2": 1070, "rot": 90}
      },
      "tags": []
    }
  }
  angle_2 = RealOutput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": 960, "x2": 550, "y2": 1060, "rot": 90}
      },
      "tags": []
    }
  }
  angle_3 = RealOutput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 770, "y1": 960, "x2": 870, "y2": 1060, "rot": 90}
      },
      "tags": []
    }
  }
  variable R_rel::Real[3, 3]
  variable angles::Angle[3]
relations
  # Sensor exerts no forces or torques
  frame_a.f = [0, 0, 0]
  frame_a.tau = [0, 0, 0]
  frame_b.f = [0, 0, 0]
  frame_b.tau = [0, 0, 0]
  # Relative rotation: from frame_a to frame_b
  R_rel = frame_b.R * transpose(frame_a.R)
  # Extract angles
  angles = axes_rotationangles(R_rel, sequence)
  [angle_1, angle_2, angle_3] = angles
metadata {
  "Dyad": {
    "icons": {"default": "dyad://MultibodyComponents/TwoFrameSensor.svg"},
    "labels": [
      {
        "label": "$(instance)",
        "x": 500,
        "y": 150,
        "rot": 0,
        "attrs": {"font-size": "140"}
      },
      {"label": "rel ang", "x": 500, "y": 680, "rot": 0}
    ]
  }
}
end
```

```dyad
"""
Measures relative Euler/Cardan angles between two frames.

Computes the three rotation angles to rotate `frame_a` into `frame_b`
for the given axis `sequence` (default: [1,2,3] = XYZ).
This is a sensor: no forces or torques are exerted.
"""
component RelativeAngles
  frame_a = Frame3D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -50, "y1": 450, "x2": 50, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  frame_b = Frame3D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 950, "y1": 450, "x2": 1050, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  structural parameter sequence::Integer[3] = [1, 2, 3]
  angle_1 = RealOutput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 130, "y1": 970, "x2": 230, "y2": 1070, "rot": 90}
      },
      "tags": []
    }
  }
  angle_2 = RealOutput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": 960, "x2": 550, "y2": 1060, "rot": 90}
      },
      "tags": []
    }
  }
  angle_3 = RealOutput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 770, "y1": 960, "x2": 870, "y2": 1060, "rot": 90}
      },
      "tags": []
    }
  }
  variable R_rel::Real[3, 3]
  variable angles::Angle[3]
relations
  # Sensor exerts no forces or torques
  frame_a.f = [0, 0, 0]
  frame_a.tau = [0, 0, 0]
  frame_b.f = [0, 0, 0]
  frame_b.tau = [0, 0, 0]
  # Relative rotation: from frame_a to frame_b
  R_rel = frame_b.R * transpose(frame_a.R)
  # Extract angles
  angles = axes_rotationangles(R_rel, sequence)
  [angle_1, angle_2, angle_3] = angles
metadata {
  "Dyad": {
    "icons": {"default": "dyad://MultibodyComponents/TwoFrameSensor.svg"},
    "labels": [
      {
        "label": "$(instance)",
        "x": 500,
        "y": 150,
        "rot": 0,
        "attrs": {"font-size": "140"}
      },
      {"label": "rel ang", "x": 500, "y": 680, "rot": 0}
    ]
  }
}
end
```

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses
