fixed typo leading to artifacts in catmull-rom splines in extreme cases

This commit is contained in:
Alberto Griggio 2018-08-12 23:20:31 +02:00
parent 0d7d1cfc8c
commit 2f2065cf9a

View File

@ -367,7 +367,7 @@ void catmull_rom_chain(int n_points, int n_cp, double *x, double *y,
xr = x[n_cp-1] - x[n_cp-2]; xr = x[n_cp-1] - x[n_cp-2];
yr = y[n_cp-1] - x[n_cp-2]; yr = y[n_cp-1] - x[n_cp-2];
double x_last = x[n_cp-1] + xr * 0.01; double x_last = x[n_cp-1] + xr * 0.01;
double y_last = xr > epsilon ? (yr / xr) * (x_last - x[0]) + y[0] : y[0]; double y_last = xr > epsilon ? (yr / xr) * (x_last - x[n_cp-1]) + y[n_cp-1] : y[n_cp-1];
int segments = n_cp - 1; int segments = n_cp - 1;
int points_segments = n_points / segments; int points_segments = n_points / segments;