# `Macaw.Draw.Scale.Radial`
[🔗](https://github.com/dcoai/macaw_draw/blob/v0.1.0/lib/macaw/draw/scale/radial.ex#L1)

An angle scale: a cyclic quantity (a compass bearing, an hour of the day, a day of the
year) to radians (spec/06 §15, visualize D-30).

The mapping is `Macaw.Draw.Scale.Linear`'s with a range in radians, one full turn by
default. Angles follow `Macaw.Draw.Shape.Arc`'s convention, clockwise from 12 o'clock, so
a bearing domain `[0, 360]` puts north at the top and east at the right. `ticks/2` are
exactly `count` equal divisions of the domain, not the nice-step sequence, and `nice/1`
is identity: the domain of a cyclic quantity is its period.

    bearing = Macaw.Draw.Scale.Radial.new() |> Macaw.Draw.Scale.Radial.domain!([0, 360])
    Macaw.Draw.Scale.Radial.ticks(bearing, 4)
    #=> [0.0, 90.0, 180.0, 270.0]

# `error`

```elixir
@type error() :: {:error, [Macaw.Base.Fault.t()]}
```

A refusal: faults with their paths.

# `t`

```elixir
@type t() :: %Macaw.Draw.Scale.Radial{
  clamp?: boolean(),
  domain: [number()],
  range: [number()]
}
```

# `apply`

```elixir
@spec apply(t(), term()) :: float() | nil | error()
```

The angle of a domain value: `Macaw.Draw.Scale.Linear.apply/2` over the domain and range.

# `bandwidth`

```elixir
@spec bandwidth(t()) :: 0 | error()
```

`0`: a radial scale has no bandwidth.

# `clamp`

```elixir
@spec clamp(t(), boolean()) :: t() | error()
```

Sets clamping; answers the struct.

# `domain`

```elixir
@spec domain(t(), term()) :: {:ok, t()} | error()
```

Sets the domain, two numbers: `{:ok, scale}` or `{:error, faults}`.

# `domain!`

```elixir
@spec domain!(t(), term()) :: t()
```

`domain/2`, answering the scale or raising `Macaw.Draw.Error`.

# `invert`

```elixir
@spec invert(t(), term()) :: float() | nil | error()
```

The domain value of an angle: `Macaw.Draw.Scale.Linear.invert/2`; never clamps.

# `new`

```elixir
@spec new() :: t()
```

A radial scale: domain `[0, 1]`, range `[0, 2π]`.

# `nice`

```elixir
@spec nice(t()) :: t() | error()
```

Identity: the domain of a cyclic quantity is its period.

# `padding`

```elixir
@spec padding(t(), number()) :: t() | error()
```

Identity: a radial scale has no padding.

# `range`

```elixir
@spec range(t(), term()) :: {:ok, t()} | error()
```

Sets the range, two angles in radians: `{:ok, scale}` or `{:error, faults}`.

# `range!`

```elixir
@spec range!(t(), term()) :: t()
```

`range/2`, answering the scale or raising `Macaw.Draw.Error`.

# `ticks`

```elixir
@spec ticks(t(), number()) :: [float()] | error()
```

Exactly `count` equal divisions of the domain from `d0`: the last, `d1`, omitted when
the range is a full turn, where it falls on the first, and kept otherwise. A count below
1 answers `[]` (spec/06 §15.2).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
