Skip to contents

Default settings create a centripetal Catmull-Rom curve with the coordinates given by x and y.

Usage

create_smooth_trajectory(x, y, alpha = 0.5, epsilon = 1e-04)

Arguments

x, y

numeric vectors with points to be connected with smooth curve

alpha

single numerical value in [0, 1], controls the tightness of the curve. alpha = 0.5 (the default) yields a centripetal Catmull-Rom curve

epsilon

single numerical value, used to create phantom points. The default value should suffice for most use cases (see also link below).

Value

A data.table with the (x, y) coordinates of the smooth trajectory.

Details

This function is based on the nice run-down of smooth curves at https://apoorvaj.io/cubic-bezier-through-four-points.