Usage
The basic cycle goes like this:
- start with a list of
{x, y}tuples. These can be any combination of integers and floats. - build a
Curves.Curvestruct by passing the list of tuples intoCurves.define_curve/2 - To find a point in the curve struct, call
Curves.solve/3with a float (0.0 - 1.0)
For example:
curve = Curves.define_curve([
# {x, y}
{0, 0},
{0, 0.5},
{0.8, 0.4},
{1, 1}
])
t = 0.25 # i.e. 25% from beginning to end of the curve.
{x, y} = Curves.solve!(curve, t)
{0.1280975341796875, 0.28279876708984375} = {x, y}
Summary
Functions
Build a new Bezier Curve struct.
Given a struct, and t, find the point along the curve
See Curves.Bezier.Curve.solve!/3.
Functions
Build a new Bezier Curve struct.
Examples
iex> c = Curves.define_curve([{0.1, 0.9}, {0.5, 0.9}, {0.5, 0.1}, {0.75, 0.1}])
iex> is_struct(c, Curves.Curve)
true
Given a struct, and t, find the point along the curve
Examples
iex> c = Curves.define_curve([{0.1, 0.9}, {0.5, 0.9}, {0.5, 0.1}, {0.75, 0.1}])
iex> Curves.solve(c, 0.3)
{0.3695499897003174, 0.727199912071228}Options
:float_dtype(default: nil) | If set to an integer, passes results to Float.round(_, precision)
See Curves.Bezier.Curve.solve!/3.