Slight adjustment to curve fitting tangents
Don't let the point spacing give bias to a side.
This commit is contained in:
18
extern/curve_fit_nd/intern/curve_fit_cubic.c
vendored
18
extern/curve_fit_nd/intern/curve_fit_cubic.c
vendored
@@ -814,8 +814,22 @@ static void fit_cubic_to_points(
|
|||||||
pt_a += dims;
|
pt_a += dims;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* tan_center = (pt_a - pt_b).normalized() */
|
{
|
||||||
normalize_vn_vnvn(tan_center, pt_a, pt_b, dims);
|
#ifdef USE_VLA
|
||||||
|
double tan_center_a[dims];
|
||||||
|
double tan_center_b[dims];
|
||||||
|
#else
|
||||||
|
double *tan_center_a = alloca(sizeof(double) * dims);
|
||||||
|
double *tan_center_b = alloca(sizeof(double) * dims);
|
||||||
|
#endif
|
||||||
|
const double *pt = &points_offset[split_index * dims];
|
||||||
|
|
||||||
|
/* tan_center = ((pt_a - pt).normalized() + (pt - pt_b).normalized()).normalized() */
|
||||||
|
normalize_vn_vnvn(tan_center_a, pt_a, pt, dims);
|
||||||
|
normalize_vn_vnvn(tan_center_b, pt, pt_b, dims);
|
||||||
|
add_vn_vnvn(tan_center, tan_center_a, tan_center_b, dims);
|
||||||
|
normalize_vn(tan_center, dims);
|
||||||
|
}
|
||||||
|
|
||||||
fit_cubic_to_points(
|
fit_cubic_to_points(
|
||||||
points_offset, split_index + 1,
|
points_offset, split_index + 1,
|
||||||
|
@@ -209,6 +209,7 @@ static double len_vn(
|
|||||||
{
|
{
|
||||||
return sqrt(len_squared_vn(v0, dims));
|
return sqrt(len_squared_vn(v0, dims));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
MINLINE double normalize_vn(
|
MINLINE double normalize_vn(
|
||||||
double v0[], const uint dims)
|
double v0[], const uint dims)
|
||||||
@@ -219,7 +220,6 @@ MINLINE double normalize_vn(
|
|||||||
}
|
}
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* v_out = (v0 - v1).normalized() */
|
/* v_out = (v0 - v1).normalized() */
|
||||||
MINLINE double normalize_vn_vnvn(
|
MINLINE double normalize_vn_vnvn(
|
||||||
|
Reference in New Issue
Block a user