---
url: /dyad/dev/stdlib/BlockComponents/components/Math.WrapAngle.md
description: Dyad Math.WrapAngle docs.  Wrap angle to interval ]-π, π] or [0, 2π[.
---

# `Math.WrapAngle` {#Math.WrapAngle}

Wrap angle to interval ]-π, π] or \[0, 2π\[.

When `positiveRange` is false (default), wraps the input angle `u` to the interval ]-π, π]. When `positiveRange` is true, wraps to \[0, 2π\[.

The input and output are in radians.

This component extends from [`BlockComponents.Interfaces.SISO`](../types/Interfaces.SISO.md)

## Usage {#Usage}

`BlockComponents.Math.WrapAngle(positiveRange=false)`

## Parameters: {#Parameters:}

|            Name |                                    Description | Units | Default value |
| ---------------:| ----------------------------------------------:| -----:| -------------:|
| `positiveRange` | Use only positive output range \[0, 2π\[ if true |     – |         false |

## Connectors {#Connectors}

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

* `y` - This connector represents a real signal as an output from a component ([`RealOutput`](/stdlib/Dyad/connectors/RealOutput#RealOutput))

## Behavior {#Behavior}

$$ \begin{align}
y\left( t \right) &= ifelse\left( \mathtt{positiveRange}, mod\left( u\left( t \right), 6.2832 \right), ifelse\left( \pi < mod\left( u\left( t \right), 6.2832 \right), -6.2832 + mod\left( u\left( t \right), 6.2832 \right), mod\left( u\left( t \right), 6.2832 \right) \right) \right)
\end{align}
$$

## Source {#Source}

```dyad
"""
Wrap angle to interval ]-π, π] or [0, 2π[.

When `positiveRange` is false (default), wraps the input angle `u` to the
interval ]-π, π]. When `positiveRange` is true, wraps to [0, 2π[.

The input and output are in radians.
"""
component WrapAngle
  extends BlockComponents.Interfaces.SISO(u(units = "rad"), y(units = "rad"))
  "Use only positive output range [0, 2π[ if true"
  parameter positiveRange::Boolean = false
relations
  y = BlockComponents.wrap_angle(u, positiveRange)
metadata {
  "Dyad": {
    "labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
    "icons": {"default": "dyad://BlockComponents/WrapAngle.svg"}
  }
}
end
```

```dyad
"""
Wrap angle to interval ]-π, π] or [0, 2π[.

When `positiveRange` is false (default), wraps the input angle `u` to the
interval ]-π, π]. When `positiveRange` is true, wraps to [0, 2π[.

The input and output are in radians.
"""
component WrapAngle
  "Input signal port"
  u = RealInput() {
    "Dyad": {
      "placement": {
        "icon": {"iconName": "input", "x1": -100, "y1": 450, "x2": 0, "y2": 550, "rot": 0},
        "diagram": {"iconName": "input", "x1": -100, "y1": 450, "x2": 0, "y2": 550, "rot": 0}
      }
    }
  }
  "Output signal port"
  y = RealOutput() {
    "Dyad": {
      "placement": {
        "icon": {"iconName": "output", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0},
        "diagram": {"iconName": "output", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
      }
    }
  }
  "Use only positive output range [0, 2π[ if true"
  parameter positiveRange::Boolean = false
relations
  y = BlockComponents.wrap_angle(u, positiveRange)
metadata {
  "Dyad": {
    "labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
    "icons": {"default": "dyad://BlockComponents/WrapAngle.svg"}
  }
}
end
```

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses

* Tests
  * [`Constant`](Math.WrapAngle.md)

  * [`Sine`](Math.WrapAngle.md)

  * [`WrapAngle`](Math.WrapAngle.md)

  * [`WrapAngle`](Math.WrapAngle.md)
