---
url: /dyad/stable/stdlib/MultibodyComponents/components/PlanarMechanics.World.md
description: >-
  Dyad PlanarMechanics.World docs.  The root component for all 2D planar
  mechanics models.
---

# `PlanarMechanics.World` {#PlanarMechanics.World}

The root component for all 2D planar mechanics models.

Every planar model must include exactly one PlanarMechanics.World component. The `frame_b` is fixed at the origin with zero orientation.

Global gravity parameters (`n`, `g`) are set here and referenced by Body components via `gravity_acceleration_2d`.

## Usage {#Usage}

`MultibodyComponents.PlanarMechanics.World(render=true, n=[0, -1], g=9.80665, nominal_length=1, default_joint_length=nominal_length / 10, default_joint_width=nominal_length / 20, default_body_diameter=nominal_length / 9, default_width_fraction=20, default_arrow_diameter=nominal_length / 40, default_force_length=nominal_length / 10, default_force_width=nominal_length / 20, default_N_to_m=1000, default_Nm_to_m=1000, default_z_position=0, r_0_3d=[0, 0, 0], rot_3d=[0, 0, 0], default_body_color=[0.5019608, 0.0, 0.5019608, 1.0], default_rod_color=[0.5019608, 0.0, 0.5019608, 1.0], default_joint_color=[1, 0, 0, 1], default_prismatic_color=[0, 0.8, 1, 1], default_spring_color=[0, 0, 1, 1], default_force_color=[0, 1, 0, 0.5], default_sensor_color=[0, 1, 0, 0.5], render_ground=false, ground_length_u=2, ground_length_v=2, ground_color=[0.784, 0.784, 0.784, 1.0])`

## Parameters: {#Parameters:}

|                      Name |                                                                                                Description | Units |             Default value |
| -------------------------:| ----------------------------------------------------------------------------------------------------------:| -----:| -------------------------:|
|                  `render` |                                                                                                            |     – |                      true |
|                       `n` |                                                                gravity direction (unit vector in 2D plane) |     – |                   \[0, -1] |
|                       `g` |                                                                       gravitational acceleration magnitude |  m/s2 |                   9.80665 |
|          `nominal_length` |                                                          Nominal length for scaling visualization defaults |     – |                         1 |
|    `default_joint_length` |                                                                             Default length of joint shapes |     – |       nominal_length / 10 |
|     `default_joint_width` |                                                                              Default width of joint shapes |     – |       nominal_length / 20 |
|   `default_body_diameter` |                                                                           Default diameter of body spheres |     – |        nominal_length / 9 |
|  `default_width_fraction` |                                                           Default width fraction (width = length/fraction) |     – |                        20 |
|  `default_arrow_diameter` |                                                                               Default arrow shaft diameter |     – |       nominal_length / 40 |
|    `default_force_length` |                                                                         Default force visualization length |     – |       nominal_length / 10 |
|     `default_force_width` |                                                                          Default force visualization width |     – |       nominal_length / 20 |
|          `default_N_to_m` |                                                                          Default force arrow scaling (N/m) |     – |                      1000 |
|         `default_Nm_to_m` |                                                                        Default torque arrow scaling (Nm/m) |     – |                      1000 |
|      `default_z_position` |                                  Default out-of-plane position where the planar plane sits in the 3D world |     m |                         0 |
|                  `r_0_3d` |           Position of the planar-world origin in the 3D world frame (for embedding a planar model into 3D) |     m |                 \[0, 0, 0] |
|                  `rot_3d` | Orientation of the planar world in the 3D world as XYZ Euler angles (for embedding a planar model into 3D) |   rad |                 \[0, 0, 0] |
|      `default_body_color` |                                                                                  Default body color (RGBA) |     – | \[0.5019608,...19608, 1.0] |
|       `default_rod_color` |                                                                       Default rod/translation color (RGBA) |     – | \[0.5019608,...19608, 1.0] |
|     `default_joint_color` |                                                                                 Default joint color (RGBA) |     – |              \[1, 0, 0, 1] |
| `default_prismatic_color` |                                                                       Default prismatic joint color (RGBA) |     – |            \[0, 0.8, 1, 1] |
|    `default_spring_color` |                                                                                Default spring color (RGBA) |     – |              \[0, 0, 1, 1] |
|     `default_force_color` |                                                                          Default force/torque color (RGBA) |     – |            \[0, 1, 0, 0.5] |
|    `default_sensor_color` |                                                                                Default sensor color (RGBA) |     – |            \[0, 1, 0, 0.5] |
|           `render_ground` |                                                                   Whether to render the world ground plane |     – |                     false |
|         `ground_length_u` |                                                                        Length of ground plane along x axis |     – |                         2 |
|         `ground_length_v` |                                                                        Length of ground plane along y axis |     – |                         2 |
|            `ground_color` |                                                                             RGBA color of the ground plane |     – | \[0.784, 0.7...0.784, 1.0] |

## Connectors {#Connectors}

* `frame_b` - Coordinate system (2-dim.) fixed to the component with one cut-force and cut-torque.

All variables are resolved in the planar world frame. ([`Frame2D`](/stdlib/Dyad/connectors/Frame2D#Frame2D))

## Behavior {#Behavior}

## Source {#Source}

```dyad
"""
The root component for all 2D planar mechanics models.

Every planar model must include exactly one PlanarMechanics.World component.
The `frame_b` is fixed at the origin with zero orientation.

Global gravity parameters (`n`, `g`) are set here and referenced by
Body components via `gravity_acceleration_2d`.
"""
external component World
  frame_b = Frame2D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 950, "y1": 450, "x2": 1050, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  parameter render::Boolean = true
  "gravity direction (unit vector in 2D plane)"
  parameter n::Real[2] = [0, -1]
  "gravitational acceleration magnitude"
  parameter g::Acceleration = 9.80665
  "Nominal length for scaling visualization defaults"
  parameter nominal_length::Real = 1
  "Default length of joint shapes"
  parameter default_joint_length::Real = nominal_length / 10
  "Default width of joint shapes"
  parameter default_joint_width::Real = nominal_length / 20
  "Default diameter of body spheres"
  parameter default_body_diameter::Real = nominal_length / 9
  "Default width fraction (width = length/fraction)"
  parameter default_width_fraction::Real = 20
  "Default arrow shaft diameter"
  parameter default_arrow_diameter::Real = nominal_length / 40
  "Default force visualization length"
  parameter default_force_length::Real = nominal_length / 10
  "Default force visualization width"
  parameter default_force_width::Real = nominal_length / 20
  "Default force arrow scaling (N/m)"
  parameter default_N_to_m::Real = 1000
  "Default torque arrow scaling (Nm/m)"
  parameter default_Nm_to_m::Real = 1000
  "Default out-of-plane position where the planar plane sits in the 3D world"
  parameter default_z_position::Length = 0
  "Position of the planar-world origin in the 3D world frame (for embedding a planar model into 3D)"
  parameter r_0_3d::Position[3] = [0, 0, 0]
  "Orientation of the planar world in the 3D world as XYZ Euler angles (for embedding a planar model into 3D)"
  parameter rot_3d::Angle[3] = [0, 0, 0]
  "Default body color (RGBA)"
  parameter default_body_color::Real[4] = [0.5019608, 0.0, 0.5019608, 1.0]
  "Default rod/translation color (RGBA)"
  parameter default_rod_color::Real[4] = [0.5019608, 0.0, 0.5019608, 1.0]
  "Default joint color (RGBA)"
  parameter default_joint_color::Real[4] = [1, 0, 0, 1]
  "Default prismatic joint color (RGBA)"
  parameter default_prismatic_color::Real[4] = [0, 0.8, 1, 1]
  "Default spring color (RGBA)"
  parameter default_spring_color::Real[4] = [0, 0, 1, 1]
  "Default force/torque color (RGBA)"
  parameter default_force_color::Real[4] = [0, 1, 0, 0.5]
  "Default sensor color (RGBA)"
  parameter default_sensor_color::Real[4] = [0, 1, 0, 0.5]
  "Whether to render the world ground plane"
  parameter render_ground::Boolean = false
  "Length of ground plane along x axis"
  parameter ground_length_u::Real = 2
  "Length of ground plane along y axis"
  parameter ground_length_v::Real = 2
  "RGBA color of the ground plane"
  parameter ground_color::Real[4] = [0.784, 0.784, 0.784, 1.0]
relations
metadata {
  "Dyad": {
    "experiments": {},
    "tests": {},
    "labels": [
      {
        "label": "g = $(g)",
        "x": 70,
        "y": 970,
        "rot": 0,
        "layer": "all",
        "attrs": {
          "fill": "black",
          "font-size": "12",
          "dominant-baseline": "central",
          "text-anchor": "left"
        }
      },
      {
        "label": "n = $(n)",
        "x": 930,
        "y": 970,
        "rot": 0,
        "layer": "all",
        "attrs": {
          "fill": "black",
          "font-size": "12",
          "dominant-baseline": "central",
          "text-anchor": "left"
        }
      }
    ],
    "icons": {"default": "dyad://MultibodyComponents/World.svg"},
    "path": {},
    "doc": {"behavior": true}
  }
}
end
```

```dyad
"""
The root component for all 2D planar mechanics models.

Every planar model must include exactly one PlanarMechanics.World component.
The `frame_b` is fixed at the origin with zero orientation.

Global gravity parameters (`n`, `g`) are set here and referenced by
Body components via `gravity_acceleration_2d`.
"""
external component World
  frame_b = Frame2D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 950, "y1": 450, "x2": 1050, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  parameter render::Boolean = true
  "gravity direction (unit vector in 2D plane)"
  parameter n::Real[2] = [0, -1]
  "gravitational acceleration magnitude"
  parameter g::Acceleration = 9.80665
  "Nominal length for scaling visualization defaults"
  parameter nominal_length::Real = 1
  "Default length of joint shapes"
  parameter default_joint_length::Real = nominal_length / 10
  "Default width of joint shapes"
  parameter default_joint_width::Real = nominal_length / 20
  "Default diameter of body spheres"
  parameter default_body_diameter::Real = nominal_length / 9
  "Default width fraction (width = length/fraction)"
  parameter default_width_fraction::Real = 20
  "Default arrow shaft diameter"
  parameter default_arrow_diameter::Real = nominal_length / 40
  "Default force visualization length"
  parameter default_force_length::Real = nominal_length / 10
  "Default force visualization width"
  parameter default_force_width::Real = nominal_length / 20
  "Default force arrow scaling (N/m)"
  parameter default_N_to_m::Real = 1000
  "Default torque arrow scaling (Nm/m)"
  parameter default_Nm_to_m::Real = 1000
  "Default out-of-plane position where the planar plane sits in the 3D world"
  parameter default_z_position::Length = 0
  "Position of the planar-world origin in the 3D world frame (for embedding a planar model into 3D)"
  parameter r_0_3d::Position[3] = [0, 0, 0]
  "Orientation of the planar world in the 3D world as XYZ Euler angles (for embedding a planar model into 3D)"
  parameter rot_3d::Angle[3] = [0, 0, 0]
  "Default body color (RGBA)"
  parameter default_body_color::Real[4] = [0.5019608, 0.0, 0.5019608, 1.0]
  "Default rod/translation color (RGBA)"
  parameter default_rod_color::Real[4] = [0.5019608, 0.0, 0.5019608, 1.0]
  "Default joint color (RGBA)"
  parameter default_joint_color::Real[4] = [1, 0, 0, 1]
  "Default prismatic joint color (RGBA)"
  parameter default_prismatic_color::Real[4] = [0, 0.8, 1, 1]
  "Default spring color (RGBA)"
  parameter default_spring_color::Real[4] = [0, 0, 1, 1]
  "Default force/torque color (RGBA)"
  parameter default_force_color::Real[4] = [0, 1, 0, 0.5]
  "Default sensor color (RGBA)"
  parameter default_sensor_color::Real[4] = [0, 1, 0, 0.5]
  "Whether to render the world ground plane"
  parameter render_ground::Boolean = false
  "Length of ground plane along x axis"
  parameter ground_length_u::Real = 2
  "Length of ground plane along y axis"
  parameter ground_length_v::Real = 2
  "RGBA color of the ground plane"
  parameter ground_color::Real[4] = [0.784, 0.784, 0.784, 1.0]
relations
metadata {
  "Dyad": {
    "experiments": {},
    "tests": {},
    "labels": [
      {
        "label": "g = $(g)",
        "x": 70,
        "y": 970,
        "rot": 0,
        "layer": "all",
        "attrs": {
          "fill": "black",
          "font-size": "12",
          "dominant-baseline": "central",
          "text-anchor": "left"
        }
      },
      {
        "label": "n = $(n)",
        "x": 930,
        "y": 970,
        "rot": 0,
        "layer": "all",
        "attrs": {
          "fill": "black",
          "font-size": "12",
          "dominant-baseline": "central",
          "text-anchor": "left"
        }
      }
    ],
    "icons": {"default": "dyad://MultibodyComponents/World.svg"},
    "path": {},
    "doc": {"behavior": true}
  }
}
end
```

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses

* Tests
  * [`ActuatedPrismaticTest`](PlanarMechanics.World.md)

  * [`BodyShapePendulumTest`](PlanarMechanics.World.md)

  * [`CentrifugalTest`](PlanarMechanics.World.md)

  * [`CutForceTest`](PlanarMechanics.World.md)

  * [`CutTorqueTest`](PlanarMechanics.World.md)

  * [`OneDOFRollingWheelJointTest`](PlanarMechanics.World.md)

  * [`OneDOFSlippingWheelSegwayTest`](PlanarMechanics.World.md)

  * [`OneDOFSlippingWheelSpinningTest`](PlanarMechanics.World.md)

  * [`PlanarToMultiBodyEmbeddedTest`](PlanarMechanics.World.md)

  * [`PlanarToMultiBodyKinematicTest`](PlanarMechanics.World.md)

  * [`PlanarToMultiBodyPendulumTest`](PlanarMechanics.World.md)

  * [`PrescribedAccelerationTest`](PlanarMechanics.World.md)

  * [`PrescribedPoseTest`](PlanarMechanics.World.md)

  * [`PrescribedPositionTest`](PlanarMechanics.World.md)

  * [`PrescribedVelocityTest`](PlanarMechanics.World.md)

  * [`RelativeForceTest`](PlanarMechanics.World.md)

  * [`SensorsTest`](PlanarMechanics.World.md)

  * [`TestCableCut`](PlanarMechanics.World.md)

  * [`TestCableEndJoints`](PlanarMechanics.World.md)

  * [`TestCableNoEndJoints`](PlanarMechanics.World.md)

  * [`TestPlanarCableEndJoints`](PlanarMechanics.World.md)

  * [`TestPlanarCableNoEndJoints`](PlanarMechanics.World.md)

  * [`WorldForceTest`](PlanarMechanics.World.md)
