---
url: /dyad/dev/stdlib/MultibodyComponents/components/RevolutePlanarLoopConstraint.md
description: >-
  Dyad RevolutePlanarLoopConstraint docs.  Revolute joint for closing planar
  kinematic loops.
---

# `RevolutePlanarLoopConstraint` {#RevolutePlanarLoopConstraint}

Revolute joint for closing planar kinematic loops.

When a closed loop of parallel-axis revolute joints exists (e.g. a 4-bar linkage), one of the joints must be replaced with this variant to break the mathematical redundancy of the cut-forces perpendicular to the loop plane. This joint enforces only the two in-plane position constraints between `frame_a` and `frame_b`; the orientation is left free (determined by the rest of the loop) and torques as well as the axis-aligned cut force are set to zero.

* `n`: rotation axis (unit vector), resolved in frame_a

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

## Usage {#Usage}

`MultibodyComponents.RevolutePlanarLoopConstraint(render=true, color=world_default_joint_color(), specular_coefficient=1.5, n=[0, 0, 1], radius=world_default_joint_width() / 2, cylinder_length=world_default_joint_length(), e=n / norm_(n), nnx_a=ifelse(abs(n[1]) > 0.1, [0, 1, 0], ifelse(abs(n[2]) > 0.1, [0, 0, 1], [1, 0, 0])), ey_a=cross(n, nnx_a) / norm_(cross(n, nnx_a)), ex_a=cross(ey_a, n))`

## Parameters: {#Parameters:}

|                   Name |                                        Description | Units |             Default value |
| ----------------------:| --------------------------------------------------:| -----:| -------------------------:|
|               `render` |                                                    |     – |                      true |
|                `color` |                                                    |     – | world_defau...int_color() |
| `specular_coefficient` |                                                    |     – |                       1.5 |
|                    `n` | axis of rotation (unit vector) resolved in frame_a |     – |                 \[0, 0, 1] |
|               `radius` |      Radius of the revolute cylinder in animations |     – | world_defau...width() / 2 |
|      `cylinder_length` |      Length of the revolute cylinder in animations |     – | world_defau...nt_length() |

## 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_rel_a` | Position vector from origin of frame_a to origin of frame_b, resolved in frame_a |     m |
|     `f_c` |                                             Constraint forces along (ex_a, ey_a) |     – |
|   `R_rel` |                     Relative rotation matrix from frame_a to frame_b coordinates |     – |

## Behavior {#Behavior}

## Source {#Source}

```dyad
"""
Revolute joint for closing planar kinematic loops.

When a closed loop of parallel-axis revolute joints exists (e.g. a 4-bar
linkage), one of the joints must be replaced with this variant to break the
mathematical redundancy of the cut-forces perpendicular to the loop plane.
This joint enforces only the two in-plane position constraints between
`frame_a` and `frame_b`; the orientation is left free (determined by the
rest of the loop) and torques as well as the axis-aligned cut force are
set to zero.

- `n`: rotation axis (unit vector), resolved in frame_a
"""
component RevolutePlanarLoopConstraint
  extends PartialTwoFrames()
  extends Renderable(color = world_default_joint_color())
  shape = CylinderShape(render = render, color = color, r = frame_a.r_0, R = transpose(frame_a.R), r_shape = n * (-cylinder_length / 2), length_direction = n, length = cylinder_length, width = 2 * radius, height = 2 * radius)
  "axis of rotation (unit vector) resolved in frame_a"
  parameter n::Real[3] = [0, 0, 1]
  "Radius of the revolute cylinder in animations"
  parameter radius::Real = world_default_joint_width() / 2
  "Length of the revolute cylinder in animations"
  parameter cylinder_length::Real = world_default_joint_length()
  final parameter e::Real[3] = n / norm_(n)
  final parameter nnx_a::Real[3] = ifelse(abs(n[1]) > 0.1, [0, 1, 0], ifelse(abs(n[2]) > 0.1, [0, 0, 1], [1, 0, 0])) # WORKAROUND: ones(Bool, 3) in condition should not be required
  final parameter ey_a::Real[3] = cross(n, nnx_a) / norm_(cross(n, nnx_a))
  final parameter ex_a::Real[3] = cross(ey_a, n)
  "Position vector from origin of frame_a to origin of frame_b, resolved in frame_a"
  variable r_rel_a::Position[3]
  "Constraint forces along (ex_a, ey_a)"
  variable f_c::Real[2]
  "Relative rotation matrix from frame_a to frame_b coordinates"
  variable R_rel::Real[3, 3]
relations
  R_rel = frame_b.R * transpose(frame_a.R)
  r_rel_a = resolve2(frame_a.R, frame_b.r_0 - frame_a.r_0)
  0 = dot(ex_a, r_rel_a)
  0 = dot(ey_a, r_rel_a)
  frame_a.tau = [0, 0, 0]
  frame_b.tau = [0, 0, 0]
  frame_a.f = ex_a * f_c[1] + ey_a * f_c[2]
  frame_b.f = -R_rel * frame_a.f
  assert(abs(dot(e, r_rel_a)) <= 1e-10 and abs(dot(e, resolve2(R_rel, ex_a))) <= 1e-10 and abs(dot(e, resolve2(R_rel, ey_a))) <= 1e-10, "The RevolutePlanarLoopConstraint joint is used as cut-joint of a planar loop. However, the revolute joint is not part of a planar loop where the axis of the revolute joint (parameter n) is orthogonal to the possible movements. Either use instead joint Revolute or correct the definition of the axis vector n in the revolute joints of the planar loop.")
metadata {
  "Dyad": {
    "icons": {"default": "dyad://MultibodyComponents/RevolutePlanarLoopConstraint.svg"},
    "labels": [
      {
        "label": "$(instance)",
        "x": 500,
        "y": 200,
        "rot": 0,
        "attrs": {"font-size": "160"}
      }
    ]
  }
}
end
```

```dyad
"""
Revolute joint for closing planar kinematic loops.

When a closed loop of parallel-axis revolute joints exists (e.g. a 4-bar
linkage), one of the joints must be replaced with this variant to break the
mathematical redundancy of the cut-forces perpendicular to the loop plane.
This joint enforces only the two in-plane position constraints between
`frame_a` and `frame_b`; the orientation is left free (determined by the
rest of the loop) and torques as well as the axis-aligned cut force are
set to zero.

- `n`: rotation axis (unit vector), resolved in frame_a
"""
component RevolutePlanarLoopConstraint
  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": []
    }
  }
  parameter render::Boolean = true
  parameter color::Real[4] = [0.5, 0.5, 0.5, 1.0]
  parameter specular_coefficient::Real = 1.5
  shape = CylinderShape(render = render, color = color, r = frame_a.r_0, R = transpose(frame_a.R), r_shape = n * (-cylinder_length / 2), length_direction = n, length = cylinder_length, width = 2 * radius, height = 2 * radius)
  "axis of rotation (unit vector) resolved in frame_a"
  parameter n::Real[3] = [0, 0, 1]
  "Radius of the revolute cylinder in animations"
  parameter radius::Real = world_default_joint_width() / 2
  "Length of the revolute cylinder in animations"
  parameter cylinder_length::Real = world_default_joint_length()
  final parameter e::Real[3] = n / norm_(n)
  final parameter nnx_a::Real[3] = ifelse(abs(n[1]) > 0.1, [0, 1, 0], ifelse(abs(n[2]) > 0.1, [0, 0, 1], [1, 0, 0])) # WORKAROUND: ones(Bool, 3) in condition should not be required
  final parameter ey_a::Real[3] = cross(n, nnx_a) / norm_(cross(n, nnx_a))
  final parameter ex_a::Real[3] = cross(ey_a, n)
  "Position vector from origin of frame_a to origin of frame_b, resolved in frame_a"
  variable r_rel_a::Position[3]
  "Constraint forces along (ex_a, ey_a)"
  variable f_c::Real[2]
  "Relative rotation matrix from frame_a to frame_b coordinates"
  variable R_rel::Real[3, 3]
relations
  R_rel = frame_b.R * transpose(frame_a.R)
  r_rel_a = resolve2(frame_a.R, frame_b.r_0 - frame_a.r_0)
  0 = dot(ex_a, r_rel_a)
  0 = dot(ey_a, r_rel_a)
  frame_a.tau = [0, 0, 0]
  frame_b.tau = [0, 0, 0]
  frame_a.f = ex_a * f_c[1] + ey_a * f_c[2]
  frame_b.f = -R_rel * frame_a.f
  assert(abs(dot(e, r_rel_a)) <= 1e-10 and abs(dot(e, resolve2(R_rel, ex_a))) <= 1e-10 and abs(dot(e, resolve2(R_rel, ey_a))) <= 1e-10, "The RevolutePlanarLoopConstraint joint is used as cut-joint of a planar loop. However, the revolute joint is not part of a planar loop where the axis of the revolute joint (parameter n) is orthogonal to the possible movements. Either use instead joint Revolute or correct the definition of the axis vector n in the revolute joints of the planar loop.")
metadata {
  "Dyad": {
    "icons": {"default": "dyad://MultibodyComponents/RevolutePlanarLoopConstraint.svg"},
    "labels": [
      {
        "label": "$(instance)",
        "x": 500,
        "y": 200,
        "rot": 0,
        "attrs": {"font-size": "160"}
      }
    ]
  }
}
end
```

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses
