---
url: /dyad/stable/stdlib/MultibodyComponents/components/BodyShape.md
description: >-
  Dyad BodyShape docs.  Body with shape: a rigid rod (FixedTranslation) from
  frame_a to frame_b with a Body attached at the center of mass via a second
  FixedTransla...
---

# `BodyShape` {#BodyShape}

Body with shape: a rigid rod (`FixedTranslation`) from `frame_a` to `frame_b` with a `Body` attached at the center of mass via a second `FixedTranslation`.

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

## Usage {#Usage}

`MultibodyComponents.BodyShape(render=true, color=world_default_body_color(), specular_coefficient=1.5, m=1, r=[0, 0, 0], r_cm=r / 2, I_11=0.001, I_22=0.001, I_33=0.001, I_21=0, I_31=0, I_32=0, radius=world_default_body_diameter() / 2, shapefile="", shape_transform=[[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]], shape_scale=1, height=0, width=0, shape="cylinder", r_length=norm_(r), r_dir=r / max(r_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 |
|        `point_gravity` |                                                                         Use a point-gravity field pointing towards the world origin (structural; see Body) |     – |                     false |
|               `render` |                                                                                                                                                            |     – |                      true |
|                `color` |                                                                                                                                                            |     – | world_defau...ody_color() |
| `specular_coefficient` |                                                                                                                                                            |     – |                       1.5 |
|                    `m` |                                                                                                                                                       mass |    kg |                         1 |
|                    `r` |                                                                                                         Vector from frame_a to frame_b resolved in frame_a |     m |                 \[0, 0, 0] |
|                 `r_cm` |                                                                                                 Vector from frame_a to center of mass, resolved in frame_a |     m |                     r / 2 |
|                 `I_11` |                                                                                                                            Element (1,1) of inertia tensor | kg.m2 |                     0.001 |
|                 `I_22` |                                                                                                                            Element (2,2) of inertia tensor | kg.m2 |                     0.001 |
|                 `I_33` |                                                                                                                            Element (3,3) of inertia tensor | kg.m2 |                     0.001 |
|                 `I_21` |                                                                                                                            Element (2,1) of inertia tensor | kg.m2 |                         0 |
|                 `I_31` |                                                                                                                            Element (3,1) of inertia tensor | kg.m2 |                         0 |
|                 `I_32` |                                                                                                                            Element (3,2) of inertia tensor | kg.m2 |                         0 |
|               `radius` |                                                                                                                           Radius of the body in animations |     – | world_defau...meter() / 2 |
|            `shapefile` |                                                                                                                                                            |     – |                        "" |
|      `shape_transform` |                                                                                                                                                            |     – | \[1 0 0 0; 0...0; 0 0 0 1] |
|          `shape_scale` |                                                                                                                                                            |     – |                         1 |
|               `height` |                                                                                                        Height of the body in animations (if shape = "box") |     – |                         0 |
|                `width` |                                                                                                         Width of the body in animations (if shape = "box") |     – |                         0 |
|                `shape` |                                                                                                                                                            |     – |                "cylinder" |

## 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_cm` - 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
"""
Body with shape: a rigid rod (`FixedTranslation`) from `frame_a` to `frame_b`
with a `Body` attached at the center of mass via a second `FixedTranslation`.
"""
component BodyShape
  extends Renderable(color = world_default_body_color())
  frame_a = Frame3D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 0, "y1": 450, "x2": 100, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  frame_b = Frame3D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 900, "y1": 450, "x2": 1000, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Additional frame at the center of mass location"
  frame_cm = Frame3D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": 450, "x2": 550, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  # Sub-components
  translation = FixedTranslation(final r = r, render = false) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": 600, "x2": 550, "y2": 700, "rot": 0}
      },
      "tags": []
    }
  }
  translation_cm = FixedTranslation(final r = r_cm, render = false) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 270, "y1": 450, "x2": 370, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  body = Body(final m = m, final r_cm = [0, 0, 0], 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, point_gravity = point_gravity, render = false) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 360, "y1": 340, "x2": 460, "y2": 440, "rot": 270}
      },
      "tags": []
    }
  }
  # Visualization shape for the rod
  rod_shape = CylinderShape(render = render, color = color, r = frame_a.r_0, R = transpose(frame_a.R), length_direction = r_dir, length = r_length, width = 2 * radius, height = 2 * radius)
  "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
  "Use a point-gravity field pointing towards the world origin (structural; see Body)"
  structural parameter point_gravity::Boolean = false
  "mass"
  parameter m::Mass = 1
  "Vector from frame_a to frame_b resolved in frame_a"
  parameter r::Length[3] = [0, 0, 0]
  "Vector from frame_a to center of mass, resolved in frame_a"
  parameter r_cm::Length[3] = r / 2
  "Element (1,1) of inertia tensor"
  parameter I_11::Inertia = 0.001
  "Element (2,2) of inertia tensor"
  parameter I_22::Inertia = 0.001
  "Element (3,3) of inertia tensor"
  parameter I_33::Inertia = 0.001
  "Element (2,1) of inertia tensor"
  parameter I_21::Inertia = 0
  "Element (3,1) of inertia tensor"
  parameter I_31::Inertia = 0
  "Element (3,2) of inertia tensor"
  parameter I_32::Inertia = 0
  "Radius of the body in animations"
  parameter radius::Real = world_default_body_diameter() / 2
  parameter shapefile::String = ""
  parameter shape_transform::Real[4, 4] = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]
  parameter shape_scale::Real = 1
  """
  Height of the body in animations (if shape = "box")
  """
  parameter height::Real = 0
  """
  Width of the body in animations (if shape = "box")
  """
  parameter width::Real = 0
  parameter shape::String = "cylinder"
  final parameter r_length::Real = norm_(r)
  final parameter r_dir::Real[3] = r / max(r_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
  r_0 = frame_a.r_0
  v_0 = der(r_0)
  a_0 = der(v_0)
  connect(frame_a, translation.frame_a, translation_cm.frame_a) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [], "E": -1},
        {"S": -1, "M": [{"x": 230, "y": 500}, {"x": 230, "y": 650}], "E": 2},
        {"S": 3, "M": [], "E": -1}
      ],
      "junctions": [{"x": 230, "y": 500}],
      "renderStyle": "standard"
    }
  }
  connect(translation.frame_b, frame_b) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 770, "y": 650}, {"x": 770, "y": 500}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(translation_cm.frame_b, body.frame_a) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 410, "y": 500}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(frame_cm, translation_cm.frame_b) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {
  "Dyad": {
    "icons": {"default": "dyad://MultibodyComponents/BodyShape.svg"},
    "labels": [
      {
        "label": "$(instance)",
        "x": 500,
        "y": 240,
        "rot": 0,
        "attrs": {"font-size": "160"}
      }
    ]
  }
}
end
```

```dyad
"""
Body with shape: a rigid rod (`FixedTranslation`) from `frame_a` to `frame_b`
with a `Body` attached at the center of mass via a second `FixedTranslation`.
"""
component BodyShape
  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": 0, "y1": 450, "x2": 100, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  frame_b = Frame3D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 900, "y1": 450, "x2": 1000, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Additional frame at the center of mass location"
  frame_cm = Frame3D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": 450, "x2": 550, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  # Sub-components
  translation = FixedTranslation(final r = r, render = false) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": 600, "x2": 550, "y2": 700, "rot": 0}
      },
      "tags": []
    }
  }
  translation_cm = FixedTranslation(final r = r_cm, render = false) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 270, "y1": 450, "x2": 370, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  body = Body(final m = m, final r_cm = [0, 0, 0], 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, point_gravity = point_gravity, render = false) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 360, "y1": 340, "x2": 460, "y2": 440, "rot": 270}
      },
      "tags": []
    }
  }
  # Visualization shape for the rod
  rod_shape = CylinderShape(render = render, color = color, r = frame_a.r_0, R = transpose(frame_a.R), length_direction = r_dir, length = r_length, width = 2 * radius, height = 2 * radius)
  "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
  "Use a point-gravity field pointing towards the world origin (structural; see Body)"
  structural parameter point_gravity::Boolean = false
  "mass"
  parameter m::Mass = 1
  "Vector from frame_a to frame_b resolved in frame_a"
  parameter r::Length[3] = [0, 0, 0]
  "Vector from frame_a to center of mass, resolved in frame_a"
  parameter r_cm::Length[3] = r / 2
  "Element (1,1) of inertia tensor"
  parameter I_11::Inertia = 0.001
  "Element (2,2) of inertia tensor"
  parameter I_22::Inertia = 0.001
  "Element (3,3) of inertia tensor"
  parameter I_33::Inertia = 0.001
  "Element (2,1) of inertia tensor"
  parameter I_21::Inertia = 0
  "Element (3,1) of inertia tensor"
  parameter I_31::Inertia = 0
  "Element (3,2) of inertia tensor"
  parameter I_32::Inertia = 0
  "Radius of the body in animations"
  parameter radius::Real = world_default_body_diameter() / 2
  parameter shapefile::String = ""
  parameter shape_transform::Real[4, 4] = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]
  parameter shape_scale::Real = 1
  """
  Height of the body in animations (if shape = "box")
  """
  parameter height::Real = 0
  """
  Width of the body in animations (if shape = "box")
  """
  parameter width::Real = 0
  parameter shape::String = "cylinder"
  final parameter r_length::Real = norm_(r)
  final parameter r_dir::Real[3] = r / max(r_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
  r_0 = frame_a.r_0
  v_0 = der(r_0)
  a_0 = der(v_0)
  connect(frame_a, translation.frame_a, translation_cm.frame_a) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [], "E": -1},
        {"S": -1, "M": [{"x": 230, "y": 500}, {"x": 230, "y": 650}], "E": 2},
        {"S": 3, "M": [], "E": -1}
      ],
      "junctions": [{"x": 230, "y": 500}],
      "renderStyle": "standard"
    }
  }
  connect(translation.frame_b, frame_b) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 770, "y": 650}, {"x": 770, "y": 500}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(translation_cm.frame_b, body.frame_a) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 410, "y": 500}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(frame_cm, translation_cm.frame_b) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {
  "Dyad": {
    "icons": {"default": "dyad://MultibodyComponents/BodyShape.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

* Tests
  * [`BodyShapePendulumTest`](BodyShape.md)
