[ANN] CatmullRom.jl (centripetal splines)

CatmullRom.jl is an easily used approach to fast, attractive curvilinear blending. Catmull-Rom splines are a mathematical workhorse of computational graphics, animation and visualization. Applied to a sequence of points, the result is an interpolatory curvilinear path, one that appears smooth and seems context appropriate. Applied to multipoint motion, action has a nicely natural path and dynamic feel.

This easy-to-use package transforms a sequence of 2D, 3D,… or ND points into a longer sequence by adding new points between adjacent pairs of the given points. So the result one obtains matches in its first and last points and contains all given points in their original order.

You can specify the number of new points to be placed between every adjacent pair of points. If there are 12 points in an open path (11 pairs of neighbors), and 8 additional points are placed between each pair, the result is a sequence of 100 points: 12 + (11 * 8) = 12 + 88 = 100.

path = catmullrom(<sequence_of_points>, <n_between_neighbors>)

Sometimes it is useful to place more new points between adjacent pairs that are relatively more distant and place fewer new points between adjacent pairs that are relatively closer. You can constrain the the actual counts of new points between any adjacent pair and let me do that.

path = catmullrom_by_arclength(<sequence>, (<at_least_n1, at_most_n2>))

You may work with open paths or with closed paths. A closed path is a point sequence where the first point and the last point have identical coordinantes. To ensure that a sequence of points is properly closed, use close_seq!(<sequence>). If the first and last points have only tiny differences, a copy of the first point overwrites the last. Otherwise, if they differ at all, push! a copy of the first point.

11 Likes