Curves.Utils.Types (curves v0.2.3)

Copy Markdown View Source

A collection of typespecs to be used in other modules. There are no meaningful functions to be found here.

Summary

Types

A single number, represented as either x or y in 2D space

@TODO WIP A keyword list of options.

The order of a curve is (the number of control points) - 1. Although a more accurate definition might be "the depth of recursion when interpolating".

An Nx tensor representing a single point

A list of {x, y} number coordinates

Provides a formal structure for the {2, n} Tensors that represent a series of n points with two dimension values (x and y)

An {x, y} pair representing a coordinate in 2D space

An Nx tensor representing a series of points

Types

coord()

@type coord() :: number()

A single number, represented as either x or y in 2D space

opts()

@type opts() :: keyword()

@TODO WIP A keyword list of options.

order()

@type order() :: 1 | 2 | 3

The order of a curve is (the number of control points) - 1. Although a more accurate definition might be "the depth of recursion when interpolating".

Linear == 1
Quadratic == 2
Cubic == 3

So for example, if you have a straight line (formed from only 2 points) and want to find a new point at 50%, you are interpolating exactly 1 time to do so.

If you have a quadratic, with 3 points, you first interpolate between p0->p1 and p1->p2, thus creating two new dots. Then you recurse, creating a new line from those new dots, and interpolate again.

Cubic curves would recursively interpolate once more.

point()

@type point() :: %Nx.Tensor{
  data: term(),
  names: point_names(),
  shape: {2, 1},
  type: {:f, pos_integer()},
  vectorized_axes: term()
}

An Nx tensor representing a single point

point_list()

@type point_list() :: [point_tuple()]

A list of {x, y} number coordinates

point_names()

@type point_names() :: [:dimension | :point]

Provides a formal structure for the {2, n} Tensors that represent a series of n points with two dimension values (x and y)

point_tuple()

@type point_tuple() :: {x :: coord(), y :: coord()}

An {x, y} pair representing a coordinate in 2D space

points()

@type points() :: %Nx.Tensor{
  data: term(),
  names: point_names(),
  shape: {2, pos_integer()},
  type: {:f, pos_integer()},
  vectorized_axes: term()
}

An Nx tensor representing a series of points