---
url: /dyad/stable/stdlib/MultibodyComponents/components/BodyCylinder.md
description: >-
  Dyad BodyCylinder docs.  Rigid body with cylinder shape. Mass properties are
  computed from the cylinder geometry and density. Optionally hollow
  (innerdiameter > 0). ...
---

# `BodyCylinder` {#BodyCylinder}

Rigid body with cylinder shape. Mass properties are computed from the cylinder geometry and density. Optionally hollow (inner_diameter > 0). The two connector frames `frame_a`and`frame_b` are always parallel.

This component extends from [`Renderable`](../types/Renderable.md)

## Usage {#Usage}

`MultibodyComponents.BodyCylinder(render=true, color=world_default_body_color(), specular_coefficient=1.5, r=[0.1, 0, 0], r_shape=[0, 0, 0], diameter=0.05, inner_diameter=0, density=7700, dir=r - r_shape, length=norm_(dir), radius=diameter / 2, inner_radius=inner_diameter / 2, mo=density * pi * length * radius ^ 2, mi=density * pi * length * inner_radius ^ 2, m=mo - mi, r_cm=r_shape + normalize_(dir) * length / 2, R_body=from_nxy(r, [0, 1, 0]), I_diag_1=(mo * radius ^ 2 - mi * inner_radius ^ 2) / 2, I_diag_2=(mo * (length ^ 2 + 3 * radius ^ 2) - mi * (length ^ 2 + 3 * inner_radius ^ 2)) / 12, I_body=resolve_dyade1(R_body, [[I_diag_1, 0, 0], [0, I_diag_2, 0], [0, 0, I_diag_2]]), I_11=I_body[1, 1], I_22=I_body[2, 2], I_33=I_body[3, 3], I_21=I_body[2, 1], I_31=I_body[3, 1], I_32=I_body[3, 2], dir_normalized=dir / max(length, 1e-10))`

## Parameters: {#Parameters:}

|                   Name |                                                                                                                                                Description | Units |             Default value |
| ----------------------:| ----------------------------------------------------------------------------------------------------------------------------------------------------------:| -----:| -------------------------:|
|    `orientation_state` | Orientation state carried by the internal body (None / Euler / Quaternion). Set to Euler or Quaternion to use this component as a freely-moving root body. |     – |   OrientationState.None() |
|             `sequence` |                                                                                                   Euler-angle sequence used when orientation_state = Euler |     – |                 \[1, 2, 3] |
|        `statePriority` |                                                                                                                     State priority of the rotational state |     – |                        10 |
|  `linearStatePriority` |                                                                                                     State priority of the linear (position/velocity) state |     – |                         1 |
|               `render` |                                                                                                                                                            |     – |                      true |
|                `color` |                                                                                                                                                            |     – | world_defau...ody_color() |
| `specular_coefficient` |                                                                                                                                                            |     – |                       1.5 |
|                    `r` |                                                                                                         Vector from frame_a to frame_b resolved in frame_a |     m |               \[0.1, 0, 0] |
|              `r_shape` |                                                                                                Vector from frame_a to cylinder origin, resolved in frame_a |     m |                 \[0, 0, 0] |
|             `diameter` |                                                                                                                                       Diameter of cylinder |     m |                      0.05 |
|       `inner_diameter` |                                                                                         Inner diameter of cylinder (0 <= inner_diameter <= diameter) |     m |                         0 |
|              `density` |                                                                                                                                Density of cylinder \[kg/m³] |     – |                      7700 |

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

## Variables {#Variables}

|  Name |                                                         Description | Units |
| -----:| -------------------------------------------------------------------:| -----:|
| `r_0` |     Position vector from origin of world frame to origin of frame_a |     m |
| `v_0` |    Absolute velocity of frame_a, resolved in world frame (= D(r_0)) |   m/s |
| `a_0` | Absolute acceleration of frame_a resolved in world frame (= D(v_0)) |  m/s2 |

## Behavior {#Behavior}

## Source {#Source}

```dyad
"""
Rigid body with cylinder shape. Mass properties are computed from the
cylinder geometry and density. Optionally hollow (inner_diameter > 0).
The two connector frames `frame_a` and `frame_b` are always parallel.
"""
component BodyCylinder
  extends Renderable(color = world_default_body_color())
  frame_a = Frame3D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 50, "y1": 450, "x2": 150, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  frame_b = Frame3D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 850, "y1": 450, "x2": 950, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  # Sub-components
  translation = FixedTranslation(final r = r, render = false)
  body = Body(final m = m, final r_cm = r_cm, final I_11 = I_11, final I_22 = I_22, final I_33 = I_33, final I_21 = I_21, final I_31 = I_31, final I_32 = I_32, orientation_state = orientation_state, sequence = sequence, statePriority = statePriority, linearStatePriority = linearStatePriority, render = false)
  # Visualization shape
  cylinder_shape = CylinderShape(render = render, color = color, r = frame_a.r_0, R = transpose(frame_a.R), r_shape = r_shape, length_direction = dir_normalized, length = length, width = diameter, height = diameter)
  "Orientation state carried by the internal body (None / Euler / Quaternion). Set to Euler or Quaternion to use this component as a freely-moving root body."
  structural parameter orientation_state::OrientationState = OrientationState.None()
  "Euler-angle sequence used when orientation_state = Euler"
  structural parameter sequence::Integer[3] = [1, 2, 3]
  "State priority of the rotational state"
  structural parameter statePriority::Integer = 10
  "State priority of the linear (position/velocity) state"
  structural parameter linearStatePriority::Integer = 1
  "Vector from frame_a to frame_b resolved in frame_a"
  parameter r::Length[3] = [0.1, 0, 0]
  "Vector from frame_a to cylinder origin, resolved in frame_a"
  parameter r_shape::Length[3] = [0, 0, 0]
  "Diameter of cylinder"
  parameter diameter::Length = 0.05
  "Inner diameter of cylinder (0 <= inner_diameter <= diameter)"
  parameter inner_diameter::Length = 0
  "Density of cylinder [kg/m³]"
  parameter density::Real = 7700
  # Computed parameters
  final parameter dir::Length[3] = r - r_shape
  final parameter length::Length = norm_(dir)
  final parameter radius::Length = diameter / 2
  final parameter inner_radius::Length = inner_diameter / 2
  final parameter mo::Mass = density * pi * length * radius ^ 2
  final parameter mi::Mass = density * pi * length * inner_radius ^ 2
  final parameter m::Mass = mo - mi
  final parameter r_cm::Length[3] = r_shape + normalize_(dir) * length / 2
  final parameter R_body::Real[3, 3] = from_nxy(r, [0, 1, 0])
  final parameter I_diag_1::Inertia = (mo * radius ^ 2 - mi * inner_radius ^ 2) / 2
  final parameter I_diag_2::Inertia = (mo * (length ^ 2 + 3 * radius ^ 2) - mi * (length ^ 2 + 3 * inner_radius ^ 2)) / 12
  final parameter I_body::Inertia[3, 3] = resolve_dyade1(R_body, [[I_diag_1, 0, 0], [0, I_diag_2, 0], [0, 0, I_diag_2]])
  final parameter I_11::Inertia = I_body[1, 1]
  final parameter I_22::Inertia = I_body[2, 2]
  final parameter I_33::Inertia = I_body[3, 3]
  final parameter I_21::Inertia = I_body[2, 1]
  final parameter I_31::Inertia = I_body[3, 1]
  final parameter I_32::Inertia = I_body[3, 2]
  final parameter dir_normalized::Real[3] = dir / max(length, 1e-10)
  "Position vector from origin of world frame to origin of frame_a"
  variable r_0::Position[3]
  "Absolute velocity of frame_a, resolved in world frame (= D(r_0))"
  variable v_0::Velocity[3]
  "Absolute acceleration of frame_a resolved in world frame (= D(v_0))"
  variable a_0::Acceleration[3]
relations
  assert(inner_diameter < diameter, "parameter inner_diameter is greater than parameter diameter")
  r_0 = frame_a.r_0
  v_0 = der(r_0)
  a_0 = der(v_0)
  connect(frame_a, translation.frame_a)
  connect(frame_b, translation.frame_b)
  connect(frame_a, body.frame_a)
metadata {
  "Dyad": {
    "icons": {"default": "dyad://MultibodyComponents/BodyCylinder.svg"},
    "labels": [
      {
        "label": "$(instance)",
        "x": 500,
        "y": 240,
        "rot": 0,
        "attrs": {"font-size": "160"}
      }
    ]
  }
}
end
```

```dyad
"""
Rigid body with cylinder shape. Mass properties are computed from the
cylinder geometry and density. Optionally hollow (inner_diameter > 0).
The two connector frames `frame_a` and `frame_b` are always parallel.
"""
component BodyCylinder
  parameter render::Boolean = true
  parameter color::Real[4] = [0.5, 0.5, 0.5, 1.0]
  parameter specular_coefficient::Real = 1.5
  frame_a = Frame3D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 50, "y1": 450, "x2": 150, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  frame_b = Frame3D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 850, "y1": 450, "x2": 950, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  # Sub-components
  translation = FixedTranslation(final r = r, render = false)
  body = Body(final m = m, final r_cm = r_cm, final I_11 = I_11, final I_22 = I_22, final I_33 = I_33, final I_21 = I_21, final I_31 = I_31, final I_32 = I_32, orientation_state = orientation_state, sequence = sequence, statePriority = statePriority, linearStatePriority = linearStatePriority, render = false)
  # Visualization shape
  cylinder_shape = CylinderShape(render = render, color = color, r = frame_a.r_0, R = transpose(frame_a.R), r_shape = r_shape, length_direction = dir_normalized, length = length, width = diameter, height = diameter)
  "Orientation state carried by the internal body (None / Euler / Quaternion). Set to Euler or Quaternion to use this component as a freely-moving root body."
  structural parameter orientation_state::OrientationState = OrientationState.None()
  "Euler-angle sequence used when orientation_state = Euler"
  structural parameter sequence::Integer[3] = [1, 2, 3]
  "State priority of the rotational state"
  structural parameter statePriority::Integer = 10
  "State priority of the linear (position/velocity) state"
  structural parameter linearStatePriority::Integer = 1
  "Vector from frame_a to frame_b resolved in frame_a"
  parameter r::Length[3] = [0.1, 0, 0]
  "Vector from frame_a to cylinder origin, resolved in frame_a"
  parameter r_shape::Length[3] = [0, 0, 0]
  "Diameter of cylinder"
  parameter diameter::Length = 0.05
  "Inner diameter of cylinder (0 <= inner_diameter <= diameter)"
  parameter inner_diameter::Length = 0
  "Density of cylinder [kg/m³]"
  parameter density::Real = 7700
  # Computed parameters
  final parameter dir::Length[3] = r - r_shape
  final parameter length::Length = norm_(dir)
  final parameter radius::Length = diameter / 2
  final parameter inner_radius::Length = inner_diameter / 2
  final parameter mo::Mass = density * pi * length * radius ^ 2
  final parameter mi::Mass = density * pi * length * inner_radius ^ 2
  final parameter m::Mass = mo - mi
  final parameter r_cm::Length[3] = r_shape + normalize_(dir) * length / 2
  final parameter R_body::Real[3, 3] = from_nxy(r, [0, 1, 0])
  final parameter I_diag_1::Inertia = (mo * radius ^ 2 - mi * inner_radius ^ 2) / 2
  final parameter I_diag_2::Inertia = (mo * (length ^ 2 + 3 * radius ^ 2) - mi * (length ^ 2 + 3 * inner_radius ^ 2)) / 12
  final parameter I_body::Inertia[3, 3] = resolve_dyade1(R_body, [[I_diag_1, 0, 0], [0, I_diag_2, 0], [0, 0, I_diag_2]])
  final parameter I_11::Inertia = I_body[1, 1]
  final parameter I_22::Inertia = I_body[2, 2]
  final parameter I_33::Inertia = I_body[3, 3]
  final parameter I_21::Inertia = I_body[2, 1]
  final parameter I_31::Inertia = I_body[3, 1]
  final parameter I_32::Inertia = I_body[3, 2]
  final parameter dir_normalized::Real[3] = dir / max(length, 1e-10)
  "Position vector from origin of world frame to origin of frame_a"
  variable r_0::Position[3]
  "Absolute velocity of frame_a, resolved in world frame (= D(r_0))"
  variable v_0::Velocity[3]
  "Absolute acceleration of frame_a resolved in world frame (= D(v_0))"
  variable a_0::Acceleration[3]
relations
  assert(inner_diameter < diameter, "parameter inner_diameter is greater than parameter diameter")
  r_0 = frame_a.r_0
  v_0 = der(r_0)
  a_0 = der(v_0)
  connect(frame_a, translation.frame_a)
  connect(frame_b, translation.frame_b)
  connect(frame_a, body.frame_a)
metadata {
  "Dyad": {
    "icons": {"default": "dyad://MultibodyComponents/BodyCylinder.svg"},
    "labels": [
      {
        "label": "$(instance)",
        "x": 500,
        "y": 240,
        "rot": 0,
        "attrs": {"font-size": "160"}
      }
    ]
  }
}
end
```

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses
