---
url: /dyad/stable/stdlib/MultibodyComponents/components/PlanarMechanics.WorldForceTorque.md
description: >-
  Dyad PlanarMechanics.WorldForceTorque docs.  External force and torque acting
  at frame_b, defined by input signals.
---

# `PlanarMechanics.WorldForceTorque` {#PlanarMechanics.WorldForceTorque}

External force and torque acting at frame_b, defined by input signals.

The force inputs (force_x, force_y) and torque input are resolved in either the world frame or frame_b, controlled by the structural parameter `resolve_in_frame`.

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

## Usage {#Usage}

`MultibodyComponents.PlanarMechanics.WorldForceTorque(render=true, color=MultibodyComponents.world_default_force_color(), specular_coefficient=1.5, scale=0.1, arrow_diameter=MultibodyComponents.world_default_arrow_diameter(), z_position=0)`

## Parameters: {#Parameters:}

|                   Name |                                                   Description | Units |             Default value |
| ----------------------:| -------------------------------------------------------------:| -----:| -------------------------:|
|     `resolve_in_frame` |                                                               |     – | MultibodyCo...ame.World() |
|               `render` |                                                               |     – |                      true |
|                `color` |                                                               |     – | MultibodyCo...rce_color() |
| `specular_coefficient` |                                                               |     – |                       1.5 |
|                `scale` | Scale factor for force visualization (length = force \* scale) |     – |                       0.1 |
|       `arrow_diameter` |                             Diameter of the force arrow shaft |     – | MultibodyCo...\_diameter() |
|           `z_position` |                         z-position of the arrow in animations |     – |                         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))

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

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

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

## Variables {#Variables}

|  Name |               Description | Units |
| -----:| -------------------------:| -----:|
| `phi` | Angle of resolution frame |   rad |

## Behavior {#Behavior}

## Source {#Source}

```dyad
"""
External force and torque acting at frame_b, defined by input signals.

The force inputs (force_x, force_y) and torque input are resolved in either the
world frame or frame_b, controlled by the structural parameter `resolve_in_frame`.
"""
component WorldForceTorque
  extends MultibodyComponents.Renderable(color = MultibodyComponents.world_default_force_color())
  frame_b = Frame2D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  force_x = RealInput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -50, "y1": 100, "x2": 50, "y2": 200, "rot": 0}
      },
      "tags": []
    }
  }
  force_y = RealInput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -50, "y1": 450, "x2": 50, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  torque = RealInput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -50, "y1": 780, "x2": 50, "y2": 880, "rot": 0}
      },
      "tags": []
    }
  }
  "Force arrow visualization"
  force_arrow = MultibodyComponents.ArrowShape(render = render, color = color, head_at_origin = true, diameter = arrow_diameter, r = [frame_b.x, frame_b.y, z_position], R = MultibodyComponents.RR(MultibodyComponents.axis_rotation(3, phi)), length_direction = [force_x, force_y, 0], width_direction = [0, 0, 1], length = sqrt(force_x ^ 2 + force_y ^ 2) * scale, width = arrow_diameter, height = arrow_diameter)
  structural parameter resolve_in_frame::MultibodyComponents.ResolveInFrame = MultibodyComponents.ResolveInFrame.World()
  "Scale factor for force visualization (length = force * scale)"
  parameter scale::Real = 0.1
  "Diameter of the force arrow shaft"
  parameter arrow_diameter::Real = MultibodyComponents.world_default_arrow_diameter()
  "z-position of the arrow in animations"
  parameter z_position::Real = 0
  "Angle of resolution frame"
  variable phi::Angle
relations
  if resolve_in_frame == MultibodyComponents.ResolveInFrame.World()
    phi = 0
  end
  if resolve_in_frame == MultibodyComponents.ResolveInFrame.FrameB()
    phi = frame_b.phi
  end
  frame_b.fx + cos(phi) * force_x - sin(phi) * force_y = 0
  frame_b.fy + sin(phi) * force_x + cos(phi) * force_y = 0
  frame_b.tau + torque = 0
metadata {
  "Dyad": {"icons": {"default": "dyad://MultibodyComponents/WorldForceTorque.svg"}}
}
end
```

```dyad
"""
External force and torque acting at frame_b, defined by input signals.

The force inputs (force_x, force_y) and torque input are resolved in either the
world frame or frame_b, controlled by the structural parameter `resolve_in_frame`.
"""
component WorldForceTorque
  parameter render::Boolean = true
  parameter color::Real[4] = [0.5, 0.5, 0.5, 1.0]
  parameter specular_coefficient::Real = 1.5
  frame_b = Frame2D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  force_x = RealInput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -50, "y1": 100, "x2": 50, "y2": 200, "rot": 0}
      },
      "tags": []
    }
  }
  force_y = RealInput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -50, "y1": 450, "x2": 50, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  torque = RealInput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -50, "y1": 780, "x2": 50, "y2": 880, "rot": 0}
      },
      "tags": []
    }
  }
  "Force arrow visualization"
  force_arrow = MultibodyComponents.ArrowShape(render = render, color = color, head_at_origin = true, diameter = arrow_diameter, r = [frame_b.x, frame_b.y, z_position], R = MultibodyComponents.RR(MultibodyComponents.axis_rotation(3, phi)), length_direction = [force_x, force_y, 0], width_direction = [0, 0, 1], length = sqrt(force_x ^ 2 + force_y ^ 2) * scale, width = arrow_diameter, height = arrow_diameter)
  structural parameter resolve_in_frame::MultibodyComponents.ResolveInFrame = MultibodyComponents.ResolveInFrame.World()
  "Scale factor for force visualization (length = force * scale)"
  parameter scale::Real = 0.1
  "Diameter of the force arrow shaft"
  parameter arrow_diameter::Real = MultibodyComponents.world_default_arrow_diameter()
  "z-position of the arrow in animations"
  parameter z_position::Real = 0
  "Angle of resolution frame"
  variable phi::Angle
relations
  if resolve_in_frame == MultibodyComponents.ResolveInFrame.World()
    phi = 0
  end
  if resolve_in_frame == MultibodyComponents.ResolveInFrame.FrameB()
    phi = frame_b.phi
  end
  frame_b.fx + cos(phi) * force_x - sin(phi) * force_y = 0
  frame_b.fy + sin(phi) * force_x + cos(phi) * force_y = 0
  frame_b.tau + torque = 0
metadata {
  "Dyad": {"icons": {"default": "dyad://MultibodyComponents/WorldForceTorque.svg"}}
}
end
```

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses

* Tests
  * [`CutTorqueTest`](PlanarMechanics.WorldForceTorque.md)

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