diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-09-25 04:34:31 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-09-25 05:19:42 +0300 |
commit | d9b242f5fbd1c7cdd3a59663250ac603dfa9ad84 (patch) | |
tree | 0ec7cd034f9ddc443087d2a80034e2d0f1cbbada /extern | |
parent | 5bdff9ea80068f5d921d818e314d6677b425c2b5 (diff) |
Curve Fitting: de-duplicate cubic evaluation
Diffstat (limited to 'extern')
-rw-r--r-- | extern/curve_fit_nd/intern/curve_fit_cubic.c | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/extern/curve_fit_nd/intern/curve_fit_cubic.c b/extern/curve_fit_nd/intern/curve_fit_cubic.c index 9b4f1869c02..1ca38505e19 100644 --- a/extern/curve_fit_nd/intern/curve_fit_cubic.c +++ b/extern/curve_fit_nd/intern/curve_fit_cubic.c @@ -255,7 +255,7 @@ static void cubic_list_clear(CubicList *clist) /** \name Cubic Evaluation * \{ */ -static void cubic_evaluate( +static void cubic_calc_point( const Cubic *cubic, const double t, const uint dims, double r_v[]) { @@ -271,18 +271,6 @@ static void cubic_evaluate( } } -static void cubic_calc_point( - const Cubic *cubic, const double t, const uint dims, - double r_v[]) -{ - CUBIC_VARS_CONST(cubic, dims, p0, p1, p2, p3); - const double s = 1.0 - t; - for (uint j = 0; j < dims; j++) { - r_v[j] = p0[j] * s * s * s + - 3.0 * t * s * (s * p1[j] + t * p2[j]) + t * t * t * p3[j]; - } -} - static void cubic_calc_speed( const Cubic *cubic, const double t, const uint dims, double r_v[]) @@ -332,7 +320,7 @@ static double cubic_calc_error( #endif for (uint i = 1; i < points_offset_len - 1; i++, pt_real += dims) { - cubic_evaluate(cubic, u[i], dims, pt_eval); + cubic_calc_point(cubic, u[i], dims, pt_eval); const double err_sq = len_squared_vnvn(pt_real, pt_eval, dims); if (err_sq >= error_max_sq) { @@ -368,7 +356,7 @@ static double cubic_calc_error_simple( #endif for (uint i = 1; i < points_offset_len - 1; i++, pt_real += dims) { - cubic_evaluate(cubic, u[i], dims, pt_eval); + cubic_calc_point(cubic, u[i], dims, pt_eval); const double err_sq = len_squared_vnvn(pt_real, pt_eval, dims); if (err_sq >= error_threshold_sq) { @@ -501,7 +489,7 @@ static double points_calc_circle_tangent_factor( return (1.0 / 3.0) * 0.75; } else if (tan_dot < -1.0 + eps) { - /* parallele tangents (half-circle) */ + /* parallel tangents (half-circle) */ return (1.0 / 2.0); } else { |