get-t-at-length
function getTAtLength(ps: number[][], s: number): number
Defined in local-properties-to-t/get-t-at-length.ts:41
Returns the t parameter value where the given bezier curve reaches the
given length s starting from t = 0.
- typically
0 <= s <= length([0,1], ps)for which the result is accurate (and0 <= t <= 1) - out-of-range values: there are no accuracy guarantees for
out-of-range values of
sbut the result is still well defined: ifsis negative0is returned and ifsis larger than the curve length up tot === 1.125then1.125is returned (i.e. the result is clipped to[0, 1.125]) - order 0: a point has zero length for all
tso0is returned regardless of the givens - the length is calculated in the same way as the
lengthfunction so thatlength([0, getTAtLength(ps, s)], ps)is (very nearly) equal tos
Note!
Green circles are draggable!
Parameters:
| Name | Type | Description |
|---|---|---|
ps | number[][] | an order 0,1,2 or 3 bezier curve given by an ordered array of its control points, e.g. [[0,0],[1,1],[2,1],[2,0]] |
s | number | the length |