17#if defined(__GNUC__) || defined(__clang__)
18#define TS_DEPRECATED __attribute__((deprecated))
19#elif defined(_MSC_VER)
20#define TS_DEPRECATED __declspec(deprecated)
24#warning "WARNING: TS_DEPRECATED is not supported by the compiler"
65#if !defined(TINYSPLINE_API)
66#if defined(_WIN32) || defined(__CYGWIN__)
67#define TINYSPLINE_SHARED_EXPORT __declspec(dllexport)
68#define TINYSPLINE_SHARED_IMPORT __declspec(dllimport)
69#elif defined(__ELF__) || defined(__MACH__)
70#define TINYSPLINE_SHARED_EXPORT __attribute__ ((visibility ("default")))
71#define TINYSPLINE_SHARED_IMPORT
73#define TINYSPLINE_SHARED_EXPORT
74#define TINYSPLINE_SHARED_IMPORT
77#ifdef TINYSPLINE_SHARED
78#ifdef TINYSPLINE_EXPORT
79#define TINYSPLINE_API TINYSPLINE_SHARED_EXPORT
81#define TINYSPLINE_API TINYSPLINE_SHARED_IMPORT
108#define TS_PI 3.14159265358979323846
121#define TS_MAX_NUM_KNOTS 10000
128#define TS_DOMAIN_DEFAULT_MIN 0.0f
135#define TS_DOMAIN_DEFAULT_MAX 1.0f
156#define TS_KNOT_EPSILON 1e-4f
166#ifdef TINYSPLINE_FLOAT_PRECISION
167#define TS_POINT_EPSILON 1e-3f
169#define TS_POINT_EPSILON 1e-5f
176#ifdef TINYSPLINE_FLOAT_PRECISION
177#define TS_LENGTH_ZERO 1e-3f
179#define TS_LENGTH_ZERO 1e-4f
210#ifdef TINYSPLINE_FLOAT_PRECISION
489#define TS_TRY(label, error, status) \
491 (error) = TS_SUCCESS; \
492 if ((status) != NULL) { \
493 (status)->code = TS_SUCCESS; \
494 (status)->message[0] = '\0'; \
499#define TS_CALL(label, error, call) \
501 if ((error)) goto __ ## label ## __;
503#define TS_CATCH(error) \
513#define TS_END_TRY_RETURN(error) \
514 TS_END_TRY return (error);
516#define TS_END_TRY_ROE(error) \
517 TS_END_TRY if ((error)) return error;
519#define TS_CALL_ROE(error, call) \
522 if ((error)) return error; \
525#define TS_RETURN_SUCCESS(status) \
527 if ((status) != NULL) { \
528 (status)->code = TS_SUCCESS; \
529 (status)->message[0] = '\0'; \
534#define TS_RETURN_0(status, error, msg) \
536 if ((status) != NULL) { \
537 (status)->code = error; \
538 sprintf((status)->message, msg); \
543#define TS_RETURN_1(status, error, msg, arg1) \
545 if ((status) != NULL) { \
546 (status)->code = error; \
547 sprintf((status)->message, msg, arg1); \
552#define TS_RETURN_2(status, error, msg, arg1, arg2) \
554 if ((status) != NULL) { \
555 (status)->code = error; \
556 sprintf((status)->message, msg, arg1, arg2); \
561#define TS_RETURN_3(status, error, msg, arg1, arg2, arg3) \
563 if ((status) != NULL) { \
564 (status)->code = error; \
565 sprintf((status)->message, msg, arg1, arg2, arg3); \
570#define TS_RETURN_4(status, error, msg, arg1, arg2, arg3, arg4) \
572 if ((status) != NULL) { \
573 (status)->code = error; \
574 sprintf((status)->message, msg, arg1, arg2, arg3, arg4); \
579#define TS_THROW_0(label, error, status, val, msg) \
582 if ((status) != NULL) { \
583 (status)->code = val; \
584 sprintf((status)->message, msg); \
586 goto __ ## label ## __; \
589#define TS_THROW_1(label, error, status, val, msg, arg1) \
592 if ((status) != NULL) { \
593 (status)->code = val; \
594 sprintf((status)->message, msg, arg1); \
596 goto __ ## label ## __; \
599#define TS_THROW_2(label, error, status, val, msg, arg1, arg2) \
602 if ((status) != NULL) { \
603 (status)->code = val; \
604 sprintf((status)->message, msg, arg1, arg2); \
606 goto __ ## label ## __; \
609#define TS_THROW_3(label, error, status, val, msg, arg1, arg2, arg3) \
612 if ((status) != NULL) { \
613 (status)->code = val; \
614 sprintf((status)->message, msg, arg1, arg2, arg3); \
616 goto __ ## label ## __; \
619#define TS_THROW_4(label, error, status, val, msg, arg1, arg2, arg3, arg4) \
622 if ((status) != NULL) { \
623 (status)->code = val; \
624 sprintf((status)->message, msg, arg1, arg2, arg3, arg4); \
626 goto __ ## label ## __; \
806const tsReal TINYSPLINE_API *
939const tsReal TINYSPLINE_API *
1331size_t TINYSPLINE_API
1342size_t TINYSPLINE_API
1355size_t TINYSPLINE_API
1369size_t TINYSPLINE_API
1380size_t TINYSPLINE_API
1391size_t TINYSPLINE_API
1403size_t TINYSPLINE_API
1419const tsReal TINYSPLINE_API *
1450size_t TINYSPLINE_API
1462size_t TINYSPLINE_API
1474size_t TINYSPLINE_API
1490const tsReal TINYSPLINE_API *
2003 int has_first_normal,
2516#if !defined(TINYSPLINE_NO_SERIALIZATION)
3049 size_t num_knot_seq,
Definition tinyspline.h:718
struct tsBSplineImpl * pImpl
Definition tinyspline.h:719
Definition tinyspline.c:45
Definition tinyspline.h:1308
struct tsDeBoorNetImpl * pImpl
Definition tinyspline.h:1309
Definition tinyspline.c:57
size_t k
Definition tinyspline.c:59
size_t dim
Definition tinyspline.c:62
Definition tinyspline.h:665
Definition tinyspline.h:477
tsError code
Definition tinyspline.h:479
tsError TINYSPLINE_API ts_bspline_knots(const tsBSpline *spline, tsReal **knots, tsStatus *status)
Definition tinyspline.c:287
tsError TINYSPLINE_API ts_bspline_set_knots_varargs(tsBSpline *spline, tsStatus *status, tsReal knot0, double knot1,...)
Definition tinyspline.c:343
size_t TINYSPLINE_API ts_deboornet_num_insertions(const tsDeBoorNet *net)
Definition tinyspline.c:605
tsError TINYSPLINE_API ts_bspline_new(size_t num_control_points, size_t dimension, size_t degree, tsBSplineType type, tsBSpline *spline, tsStatus *status)
Definition tinyspline.c:464
tsError TINYSPLINE_API ts_bspline_set_control_points(tsBSpline *spline, const tsReal *ctrlp, tsStatus *status)
Definition tinyspline.c:242
size_t TINYSPLINE_API ts_bspline_sof_control_points(const tsBSpline *spline)
Definition tinyspline.c:201
tsError TINYSPLINE_API ts_bspline_to_beziers(const tsBSpline *spline, tsBSpline *beziers, tsStatus *status)
Definition tinyspline.c:2311
void TINYSPLINE_API ts_deboornet_move(tsDeBoorNet *src, tsDeBoorNet *dest)
Definition tinyspline.c:757
void TINYSPLINE_API ts_vec3_cross(const tsReal *x, const tsReal *y, tsReal *out)
Definition tinyspline.c:3283
tsError TINYSPLINE_API ts_bspline_new_with_control_points(size_t num_control_points, size_t dimension, size_t degree, tsBSplineType type, tsBSpline *spline, tsStatus *status, double first,...)
Definition tinyspline.c:516
tsError TINYSPLINE_API ts_deboornet_points(const tsDeBoorNet *net, tsReal **points, tsStatus *status)
Definition tinyspline.c:642
void TINYSPLINE_API ts_bspline_uniform_knot_seq(const tsBSpline *spline, size_t num, tsReal *knots)
Definition tinyspline.c:1881
size_t TINYSPLINE_API ts_deboornet_len_points(const tsDeBoorNet *net)
Definition tinyspline.c:617
tsError TINYSPLINE_API ts_bspline_align(const tsBSpline *s1, const tsBSpline *s2, tsReal epsilon, tsBSpline *s1_out, tsBSpline *s2_out, tsStatus *status)
Definition tinyspline.c:2635
size_t TINYSPLINE_API ts_deboornet_dimension(const tsDeBoorNet *net)
Definition tinyspline.c:611
tsError TINYSPLINE_API ts_bspline_compute_rmf(const tsBSpline *spline, const tsReal *knots, size_t num, int has_first_normal, tsFrame *frames, tsStatus *status)
Definition tinyspline.c:1542
tsError TINYSPLINE_API ts_bspline_copy(const tsBSpline *src, tsBSpline *dest, tsStatus *status)
Definition tinyspline.c:549
tsError TINYSPLINE_API ts_chord_lengths_equidistant_knot_seq(const tsReal *knots, const tsReal *lengths, size_t num, size_t num_knot_seq, tsReal *knot_seq, tsStatus *status)
Definition tinyspline.c:3423
tsError TINYSPLINE_API ts_bspline_interpolate_cubic_natural(const tsReal *points, size_t num_points, size_t dimension, tsBSpline *spline, tsStatus *status)
Definition tinyspline.c:951
size_t TINYSPLINE_API ts_deboornet_num_points(const tsDeBoorNet *net)
Definition tinyspline.c:624
tsBSpline TINYSPLINE_API ts_bspline_init(void)
Definition tinyspline.c:406
tsError TINYSPLINE_API ts_bspline_knot_at(const tsBSpline *spline, size_t index, tsReal *knot, tsStatus *status)
Definition tinyspline.c:299
tsError TINYSPLINE_API ts_deboornet_result(const tsDeBoorNet *net, tsReal **result, tsStatus *status)
Definition tinyspline.c:679
void TINYSPLINE_API ts_vec_add(const tsReal *x, const tsReal *y, size_t dim, tsReal *out)
Definition tinyspline.c:3219
void TINYSPLINE_API ts_deboornet_free(tsDeBoorNet *net)
Definition tinyspline.c:735
tsError TINYSPLINE_API ts_bspline_set_knots(tsBSpline *spline, const tsReal *knots, tsStatus *status)
Definition tinyspline.c:308
size_t TINYSPLINE_API ts_bspline_degree(const tsBSpline *spline)
Definition tinyspline.c:170
void TINYSPLINE_API ts_arr_fill(tsReal *arr, size_t num, tsReal val)
Definition tinyspline.c:3462
size_t TINYSPLINE_API ts_bspline_sof_knots(const tsBSpline *spline)
Definition tinyspline.c:275
tsReal TINYSPLINE_API ts_deboornet_knot(const tsDeBoorNet *net)
Definition tinyspline.c:587
const tsReal TINYSPLINE_API * ts_deboornet_result_ptr(const tsDeBoorNet *net)
Definition tinyspline.c:673
size_t TINYSPLINE_API ts_deboornet_index(const tsDeBoorNet *net)
Definition tinyspline.c:593
tsError TINYSPLINE_API ts_bspline_is_closed(const tsBSpline *spline, tsReal epsilon, int *closed, tsStatus *status)
Definition tinyspline.c:1498
size_t TINYSPLINE_API ts_bspline_order(const tsBSpline *spline)
Definition tinyspline.c:176
void TINYSPLINE_API ts_bspline_free(tsBSpline *spline)
Definition tinyspline.c:573
tsError TINYSPLINE_API ts_bspline_elevate_degree(const tsBSpline *spline, size_t amount, tsReal epsilon, tsBSpline *elevated, tsStatus *status)
Definition tinyspline.c:2382
size_t TINYSPLINE_API ts_bspline_num_knots(const tsBSpline *spline)
Definition tinyspline.c:269
tsError
Definition tinyspline.h:426
@ TS_DEG_GE_NCTRLP
Definition tinyspline.h:437
@ TS_NO_RESULT
Definition tinyspline.h:467
@ TS_MULTIPLICITY
Definition tinyspline.h:443
@ TS_UNDERIVABLE
Definition tinyspline.h:452
@ TS_KNOTS_DECR
Definition tinyspline.h:446
@ TS_IO_ERROR
Definition tinyspline.h:458
@ TS_SUCCESS
Definition tinyspline.h:428
@ TS_DIM_ZERO
Definition tinyspline.h:434
@ TS_NUM_KNOTS
Definition tinyspline.h:449
@ TS_NUM_POINTS
Definition tinyspline.h:470
@ TS_LCTRLP_DIM_MISMATCH
Definition tinyspline.h:455
@ TS_U_UNDEFINED
Definition tinyspline.h:440
@ TS_PARSE_ERROR
Definition tinyspline.h:461
@ TS_MALLOC
Definition tinyspline.h:431
@ TS_INDEX_ERROR
Definition tinyspline.h:464
void TINYSPLINE_API ts_vec2_set(tsReal *out, const tsReal *x, size_t dim)
Definition tinyspline.c:3186
void TINYSPLINE_API ts_bspline_domain(const tsBSpline *spline, tsReal *min, tsReal *max)
Definition tinyspline.c:1487
void TINYSPLINE_API ts_vec_sub(const tsReal *x, const tsReal *y, size_t dim, tsReal *out)
Definition tinyspline.c:3230
tsError TINYSPLINE_API ts_bspline_parse_json(const char *json, tsBSpline *spline, tsStatus *status)
Definition tinyspline.c:3079
tsError TINYSPLINE_API ts_bspline_tension(const tsBSpline *spline, tsReal beta, tsBSpline *out, tsStatus *status)
Definition tinyspline.c:2278
tsError TINYSPLINE_API ts_bspline_eval(const tsBSpline *spline, tsReal knot, tsDeBoorNet *net, tsStatus *status)
Definition tinyspline.c:1343
void TINYSPLINE_API ts_vec4_set(tsReal *out, const tsReal *x, size_t dim)
Definition tinyspline.c:3208
tsError TINYSPLINE_API ts_bspline_control_points(const tsBSpline *spline, tsReal **ctrlp, tsStatus *status)
Definition tinyspline.c:213
tsError TINYSPLINE_API ts_bspline_load(const char *path, tsBSpline *spline, tsStatus *status)
Definition tinyspline.c:3117
tsError TINYSPLINE_API ts_bspline_chord_lengths(const tsBSpline *spline, const tsReal *knots, size_t num, tsReal *lengths, tsStatus *status)
Definition tinyspline.c:1696
tsError TINYSPLINE_API ts_chord_lengths_t_to_knot(const tsReal *knots, const tsReal *lengths, size_t num, tsReal t, tsReal *knot, tsStatus *status)
Definition tinyspline.c:3404
tsReal TINYSPLINE_API ts_vec_dot(const tsReal *x, const tsReal *y, size_t dim)
Definition tinyspline.c:3246
tsError TINYSPLINE_API ts_bspline_interpolate_catmull_rom(const tsReal *points, size_t num_points, size_t dimension, tsReal alpha, const tsReal *first, const tsReal *last, tsReal epsilon, tsBSpline *spline, tsStatus *status)
Definition tinyspline.c:1041
tsError TINYSPLINE_API ts_bspline_set_control_point_at(tsBSpline *spline, size_t index, const tsReal *ctrlp, tsStatus *status)
Definition tinyspline.c:252
size_t TINYSPLINE_API ts_bspline_dimension(const tsBSpline *spline)
Definition tinyspline.c:182
tsError TINYSPLINE_API ts_bspline_to_json(const tsBSpline *spline, char **json, tsStatus *status)
Definition tinyspline.c:3063
double tsReal
Definition tinyspline.h:213
void TINYSPLINE_API ts_vec2_init(tsReal *out, tsReal x, tsReal y)
Definition tinyspline.c:3153
const tsReal TINYSPLINE_API * ts_deboornet_points_ptr(const tsDeBoorNet *net)
Definition tinyspline.c:636
tsError TINYSPLINE_API ts_bspline_set_knot_at(tsBSpline *spline, size_t index, tsReal knot, tsStatus *status)
Definition tinyspline.c:373
tsDeBoorNet TINYSPLINE_API ts_deboornet_init(void)
Definition tinyspline.c:698
tsError TINYSPLINE_API ts_deboornet_copy(const tsDeBoorNet *src, tsDeBoorNet *dest, tsStatus *status)
Definition tinyspline.c:742
void TINYSPLINE_API ts_bspline_move(tsBSpline *src, tsBSpline *dest)
Definition tinyspline.c:564
int TINYSPLINE_API ts_knots_equal(tsReal x, tsReal y)
Definition tinyspline.c:3456
tsBSplineType
Definition tinyspline.h:642
@ TS_CLAMPED
Definition tinyspline.h:647
@ TS_BEZIERS
Definition tinyspline.h:653
@ TS_OPENED
Definition tinyspline.h:644
const tsReal TINYSPLINE_API * ts_bspline_control_points_ptr(const tsBSpline *spline)
Definition tinyspline.c:207
size_t TINYSPLINE_API ts_bspline_len_control_points(const tsBSpline *spline)
Definition tinyspline.c:188
tsError TINYSPLINE_API ts_bspline_sample(const tsBSpline *spline, size_t num, tsReal **points, size_t *actual_num, tsStatus *status)
Definition tinyspline.c:1398
tsError TINYSPLINE_API ts_bspline_sub_spline(const tsBSpline *spline, tsReal knot0, tsReal knot1, tsBSpline *sub, tsStatus *status)
Definition tinyspline.c:1748
tsError TINYSPLINE_API ts_bspline_bisect(const tsBSpline *spline, tsReal value, tsReal epsilon, int persnickety, size_t index, int ascending, size_t max_iter, tsDeBoorNet *net, tsStatus *status)
Definition tinyspline.c:1424
void TINYSPLINE_API ts_vec3_init(tsReal *out, tsReal x, tsReal y, tsReal z)
Definition tinyspline.c:3162
tsError TINYSPLINE_API ts_bspline_eval_all(const tsBSpline *spline, const tsReal *knots, size_t num, tsReal **points, tsStatus *status)
Definition tinyspline.c:1361
size_t TINYSPLINE_API ts_deboornet_len_result(const tsDeBoorNet *net)
Definition tinyspline.c:654
tsError TINYSPLINE_API ts_bspline_derive(const tsBSpline *spline, size_t n, tsReal epsilon, tsBSpline *deriv, tsStatus *status)
Definition tinyspline.c:1993
size_t TINYSPLINE_API ts_deboornet_num_result(const tsDeBoorNet *net)
Definition tinyspline.c:661
size_t TINYSPLINE_API ts_deboornet_sof_result(const tsDeBoorNet *net)
Definition tinyspline.c:667
void TINYSPLINE_API ts_vec_mul(const tsReal *x, size_t dim, tsReal val, tsReal *out)
Definition tinyspline.c:3323
const tsReal TINYSPLINE_API * ts_bspline_knots_ptr(const tsBSpline *spline)
Definition tinyspline.c:281
tsError TINYSPLINE_API ts_bspline_morph(const tsBSpline *origin, const tsBSpline *target, tsReal t, tsReal epsilon, tsBSpline *out, tsStatus *status)
Definition tinyspline.c:2735
tsError TINYSPLINE_API ts_bspline_split(const tsBSpline *spline, tsReal knot, tsBSpline *split, size_t *k, tsStatus *status)
Definition tinyspline.c:2244
tsError TINYSPLINE_API ts_bspline_control_point_at_ptr(const tsBSpline *spline, size_t index, const tsReal **ctrlp, tsStatus *status)
Definition tinyspline.c:225
tsReal TINYSPLINE_API ts_vec_angle(const tsReal *x, const tsReal *y, tsReal *buf, size_t dim)
Definition tinyspline.c:3258
tsReal TINYSPLINE_API ts_vec_mag(const tsReal *x, size_t dim)
Definition tinyspline.c:3312
void TINYSPLINE_API ts_vec3_set(tsReal *out, const tsReal *x, size_t dim)
Definition tinyspline.c:3197
tsError TINYSPLINE_API ts_bspline_save(const tsBSpline *spline, const char *path, tsStatus *status)
Definition tinyspline.c:3101
tsError TINYSPLINE_API ts_chord_lengths_length_to_knot(const tsReal *knots, const tsReal *lengths, size_t num, tsReal len, tsReal *knot, tsStatus *status)
Definition tinyspline.c:3341
size_t TINYSPLINE_API ts_deboornet_sof_points(const tsDeBoorNet *net)
Definition tinyspline.c:630
tsReal TINYSPLINE_API ts_distance(const tsReal *x, const tsReal *y, size_t dim)
Definition tinyspline.c:3471
void TINYSPLINE_API ts_vec4_init(tsReal *out, tsReal x, tsReal y, tsReal z, tsReal w)
Definition tinyspline.c:3173
size_t TINYSPLINE_API ts_bspline_num_control_points(const tsBSpline *spline)
Definition tinyspline.c:195
void TINYSPLINE_API ts_vec_norm(const tsReal *x, size_t dim, tsReal *out)
Definition tinyspline.c:3297
tsError TINYSPLINE_API ts_bspline_equidistant_knot_seq(const tsBSpline *spline, size_t num, tsReal *knots, size_t num_samples, tsStatus *status)
Definition tinyspline.c:1901
tsError TINYSPLINE_API ts_bspline_insert_knot(const tsBSpline *spline, tsReal knot, size_t num, tsBSpline *result, size_t *k, tsStatus *status)
Definition tinyspline.c:2216
size_t TINYSPLINE_API ts_deboornet_multiplicity(const tsDeBoorNet *net)
Definition tinyspline.c:599