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
84 #define TINYSPLINE_API
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 ## __; \
730 size_t TINYSPLINE_API
741 size_t TINYSPLINE_API
754 size_t TINYSPLINE_API
765 size_t TINYSPLINE_API
776 size_t TINYSPLINE_API
788 size_t TINYSPLINE_API
806 const tsReal TINYSPLINE_API *
909 size_t TINYSPLINE_API
921 size_t TINYSPLINE_API
939 const tsReal TINYSPLINE_API *
1331 size_t TINYSPLINE_API
1342 size_t TINYSPLINE_API
1355 size_t TINYSPLINE_API
1369 size_t TINYSPLINE_API
1380 size_t TINYSPLINE_API
1391 size_t TINYSPLINE_API
1403 size_t TINYSPLINE_API
1419 const tsReal TINYSPLINE_API *
1450 size_t TINYSPLINE_API
1462 size_t TINYSPLINE_API
1474 size_t TINYSPLINE_API
1490 const tsReal TINYSPLINE_API *
2003 int has_first_normal,
3048 size_t num_knot_seq,
Definition: tinyspline.c:42
Definition: tinyspline.h:718
struct tsBSplineImpl * pImpl
Definition: tinyspline.h:719
Definition: tinyspline.c:53
size_t k
Definition: tinyspline.c:55
size_t dim
Definition: tinyspline.c:58
Definition: tinyspline.h:1308
struct tsDeBoorNetImpl * pImpl
Definition: tinyspline.h:1309
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:282
tsError TINYSPLINE_API ts_bspline_set_knots_varargs(tsBSpline *spline, tsStatus *status, tsReal knot0, double knot1,...)
Definition: tinyspline.c:338
size_t TINYSPLINE_API ts_deboornet_num_insertions(const tsDeBoorNet *net)
Definition: tinyspline.c:600
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:459
const tsReal TINYSPLINE_API * ts_bspline_knots_ptr(const tsBSpline *spline)
Definition: tinyspline.c:276
tsError TINYSPLINE_API ts_bspline_set_control_points(tsBSpline *spline, const tsReal *ctrlp, tsStatus *status)
Definition: tinyspline.c:237
size_t TINYSPLINE_API ts_bspline_sof_control_points(const tsBSpline *spline)
Definition: tinyspline.c:196
tsError TINYSPLINE_API ts_bspline_to_beziers(const tsBSpline *spline, tsBSpline *beziers, tsStatus *status)
Definition: tinyspline.c:2306
void TINYSPLINE_API ts_deboornet_move(tsDeBoorNet *src, tsDeBoorNet *dest)
Definition: tinyspline.c:752
void TINYSPLINE_API ts_vec3_cross(const tsReal *x, const tsReal *y, tsReal *out)
Definition: tinyspline.c:3278
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:511
tsError TINYSPLINE_API ts_deboornet_points(const tsDeBoorNet *net, tsReal **points, tsStatus *status)
Definition: tinyspline.c:637
void TINYSPLINE_API ts_bspline_uniform_knot_seq(const tsBSpline *spline, size_t num, tsReal *knots)
Definition: tinyspline.c:1876
size_t TINYSPLINE_API ts_deboornet_len_points(const tsDeBoorNet *net)
Definition: tinyspline.c:612
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:2630
size_t TINYSPLINE_API ts_deboornet_dimension(const tsDeBoorNet *net)
Definition: tinyspline.c:606
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:1537
tsError TINYSPLINE_API ts_bspline_copy(const tsBSpline *src, tsBSpline *dest, tsStatus *status)
Definition: tinyspline.c:544
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:3418
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:946
size_t TINYSPLINE_API ts_deboornet_num_points(const tsDeBoorNet *net)
Definition: tinyspline.c:619
tsBSpline TINYSPLINE_API ts_bspline_init(void)
Definition: tinyspline.c:401
tsError TINYSPLINE_API ts_bspline_knot_at(const tsBSpline *spline, size_t index, tsReal *knot, tsStatus *status)
Definition: tinyspline.c:294
tsError TINYSPLINE_API ts_deboornet_result(const tsDeBoorNet *net, tsReal **result, tsStatus *status)
Definition: tinyspline.c:674
void TINYSPLINE_API ts_vec_add(const tsReal *x, const tsReal *y, size_t dim, tsReal *out)
Definition: tinyspline.c:3214
void TINYSPLINE_API ts_deboornet_free(tsDeBoorNet *net)
Definition: tinyspline.c:730
tsError TINYSPLINE_API ts_bspline_set_knots(tsBSpline *spline, const tsReal *knots, tsStatus *status)
Definition: tinyspline.c:303
size_t TINYSPLINE_API ts_bspline_degree(const tsBSpline *spline)
Definition: tinyspline.c:165
void TINYSPLINE_API ts_arr_fill(tsReal *arr, size_t num, tsReal val)
Definition: tinyspline.c:3457
size_t TINYSPLINE_API ts_bspline_sof_knots(const tsBSpline *spline)
Definition: tinyspline.c:270
tsReal TINYSPLINE_API ts_deboornet_knot(const tsDeBoorNet *net)
Definition: tinyspline.c:582
size_t TINYSPLINE_API ts_deboornet_index(const tsDeBoorNet *net)
Definition: tinyspline.c:588
tsError TINYSPLINE_API ts_bspline_is_closed(const tsBSpline *spline, tsReal epsilon, int *closed, tsStatus *status)
Definition: tinyspline.c:1493
size_t TINYSPLINE_API ts_bspline_order(const tsBSpline *spline)
Definition: tinyspline.c:171
void TINYSPLINE_API ts_bspline_free(tsBSpline *spline)
Definition: tinyspline.c:568
tsError TINYSPLINE_API ts_bspline_elevate_degree(const tsBSpline *spline, size_t amount, tsReal epsilon, tsBSpline *elevated, tsStatus *status)
Definition: tinyspline.c:2377
size_t TINYSPLINE_API ts_bspline_num_knots(const tsBSpline *spline)
Definition: tinyspline.c:264
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:3181
void TINYSPLINE_API ts_bspline_domain(const tsBSpline *spline, tsReal *min, tsReal *max)
Definition: tinyspline.c:1482
void TINYSPLINE_API ts_vec_sub(const tsReal *x, const tsReal *y, size_t dim, tsReal *out)
Definition: tinyspline.c:3225
tsError TINYSPLINE_API ts_bspline_parse_json(const char *json, tsBSpline *spline, tsStatus *status)
Definition: tinyspline.c:3074
tsError TINYSPLINE_API ts_bspline_tension(const tsBSpline *spline, tsReal beta, tsBSpline *out, tsStatus *status)
Definition: tinyspline.c:2273
tsError TINYSPLINE_API ts_bspline_eval(const tsBSpline *spline, tsReal knot, tsDeBoorNet *net, tsStatus *status)
Definition: tinyspline.c:1338
void TINYSPLINE_API ts_vec4_set(tsReal *out, const tsReal *x, size_t dim)
Definition: tinyspline.c:3203
tsError TINYSPLINE_API ts_bspline_control_points(const tsBSpline *spline, tsReal **ctrlp, tsStatus *status)
Definition: tinyspline.c:208
tsError TINYSPLINE_API ts_bspline_load(const char *path, tsBSpline *spline, tsStatus *status)
Definition: tinyspline.c:3112
tsError TINYSPLINE_API ts_bspline_chord_lengths(const tsBSpline *spline, const tsReal *knots, size_t num, tsReal *lengths, tsStatus *status)
Definition: tinyspline.c:1691
const tsReal TINYSPLINE_API * ts_deboornet_points_ptr(const tsDeBoorNet *net)
Definition: tinyspline.c:631
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:3399
tsReal TINYSPLINE_API ts_vec_dot(const tsReal *x, const tsReal *y, size_t dim)
Definition: tinyspline.c:3241
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:1036
tsError TINYSPLINE_API ts_bspline_set_control_point_at(tsBSpline *spline, size_t index, const tsReal *ctrlp, tsStatus *status)
Definition: tinyspline.c:247
size_t TINYSPLINE_API ts_bspline_dimension(const tsBSpline *spline)
Definition: tinyspline.c:177
tsError TINYSPLINE_API ts_bspline_to_json(const tsBSpline *spline, char **json, tsStatus *status)
Definition: tinyspline.c:3058
double tsReal
Definition: tinyspline.h:213
void TINYSPLINE_API ts_vec2_init(tsReal *out, tsReal x, tsReal y)
Definition: tinyspline.c:3148
tsError TINYSPLINE_API ts_bspline_set_knot_at(tsBSpline *spline, size_t index, tsReal knot, tsStatus *status)
Definition: tinyspline.c:368
tsDeBoorNet TINYSPLINE_API ts_deboornet_init(void)
Definition: tinyspline.c:693
tsError TINYSPLINE_API ts_deboornet_copy(const tsDeBoorNet *src, tsDeBoorNet *dest, tsStatus *status)
Definition: tinyspline.c:737
void TINYSPLINE_API ts_bspline_move(tsBSpline *src, tsBSpline *dest)
Definition: tinyspline.c:559
int TINYSPLINE_API ts_knots_equal(tsReal x, tsReal y)
Definition: tinyspline.c:3451
tsBSplineType
Definition: tinyspline.h:642
@ TS_CLAMPED
Definition: tinyspline.h:647
@ TS_BEZIERS
Definition: tinyspline.h:653
@ TS_OPENED
Definition: tinyspline.h:644
size_t TINYSPLINE_API ts_bspline_len_control_points(const tsBSpline *spline)
Definition: tinyspline.c:183
const tsReal TINYSPLINE_API * ts_bspline_control_points_ptr(const tsBSpline *spline)
Definition: tinyspline.c:202
tsError TINYSPLINE_API ts_bspline_sample(const tsBSpline *spline, size_t num, tsReal **points, size_t *actual_num, tsStatus *status)
Definition: tinyspline.c:1393
tsError TINYSPLINE_API ts_bspline_sub_spline(const tsBSpline *spline, tsReal knot0, tsReal knot1, tsBSpline *sub, tsStatus *status)
Definition: tinyspline.c:1743
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:1419
void TINYSPLINE_API ts_vec3_init(tsReal *out, tsReal x, tsReal y, tsReal z)
Definition: tinyspline.c:3157
tsError TINYSPLINE_API ts_bspline_eval_all(const tsBSpline *spline, const tsReal *knots, size_t num, tsReal **points, tsStatus *status)
Definition: tinyspline.c:1356
size_t TINYSPLINE_API ts_deboornet_len_result(const tsDeBoorNet *net)
Definition: tinyspline.c:649
tsError TINYSPLINE_API ts_bspline_derive(const tsBSpline *spline, size_t n, tsReal epsilon, tsBSpline *deriv, tsStatus *status)
Definition: tinyspline.c:1988
size_t TINYSPLINE_API ts_deboornet_num_result(const tsDeBoorNet *net)
Definition: tinyspline.c:656
size_t TINYSPLINE_API ts_deboornet_sof_result(const tsDeBoorNet *net)
Definition: tinyspline.c:662
void TINYSPLINE_API ts_vec_mul(const tsReal *x, size_t dim, tsReal val, tsReal *out)
Definition: tinyspline.c:3318
tsError TINYSPLINE_API ts_bspline_morph(const tsBSpline *origin, const tsBSpline *target, tsReal t, tsReal epsilon, tsBSpline *out, tsStatus *status)
Definition: tinyspline.c:2730
tsError TINYSPLINE_API ts_bspline_split(const tsBSpline *spline, tsReal knot, tsBSpline *split, size_t *k, tsStatus *status)
Definition: tinyspline.c:2239
tsError TINYSPLINE_API ts_bspline_control_point_at_ptr(const tsBSpline *spline, size_t index, const tsReal **ctrlp, tsStatus *status)
Definition: tinyspline.c:220
tsReal TINYSPLINE_API ts_vec_angle(const tsReal *x, const tsReal *y, tsReal *buf, size_t dim)
Definition: tinyspline.c:3253
tsReal TINYSPLINE_API ts_vec_mag(const tsReal *x, size_t dim)
Definition: tinyspline.c:3307
void TINYSPLINE_API ts_vec3_set(tsReal *out, const tsReal *x, size_t dim)
Definition: tinyspline.c:3192
tsError TINYSPLINE_API ts_bspline_save(const tsBSpline *spline, const char *path, tsStatus *status)
Definition: tinyspline.c:3096
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:3336
size_t TINYSPLINE_API ts_deboornet_sof_points(const tsDeBoorNet *net)
Definition: tinyspline.c:625
tsReal TINYSPLINE_API ts_distance(const tsReal *x, const tsReal *y, size_t dim)
Definition: tinyspline.c:3466
void TINYSPLINE_API ts_vec4_init(tsReal *out, tsReal x, tsReal y, tsReal z, tsReal w)
Definition: tinyspline.c:3168
size_t TINYSPLINE_API ts_bspline_num_control_points(const tsBSpline *spline)
Definition: tinyspline.c:190
void TINYSPLINE_API ts_vec_norm(const tsReal *x, size_t dim, tsReal *out)
Definition: tinyspline.c:3292
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:1896
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:2211
const tsReal TINYSPLINE_API * ts_deboornet_result_ptr(const tsDeBoorNet *net)
Definition: tinyspline.c:668
size_t TINYSPLINE_API ts_deboornet_multiplicity(const tsDeBoorNet *net)
Definition: tinyspline.c:594