catmull-rom: add special case for evaluating straight segments at 0 or 1
This commit is contained in:
parent
d6ca3d65aa
commit
ef57c5da00
@ -320,6 +320,14 @@ inline void catmull_rom_spline(int n_points,
|
||||
res_x.push_back(p1_x);
|
||||
res_y.push_back(p1_y);
|
||||
|
||||
// special case, a segment at 0 or 1 is computed exactly
|
||||
if (p1_y == p2_y && (p1_y == 0 || p1_y == 1)) {
|
||||
for (i = 1; i < n_points-1; ++i) {
|
||||
t = p1_x + space * i;
|
||||
res_x.push_back(t);
|
||||
res_y.push_back(p1_y);
|
||||
}
|
||||
} else {
|
||||
for (i = 1; i < n_points-1; ++i) {
|
||||
t = t1 + space * i;
|
||||
|
||||
@ -356,6 +364,7 @@ inline void catmull_rom_spline(int n_points,
|
||||
res_x.push_back(C_x);
|
||||
res_y.push_back(C_y);
|
||||
}
|
||||
}
|
||||
|
||||
res_x.push_back(p2_x);
|
||||
res_y.push_back(p2_y);
|
||||
|
Loading…
x
Reference in New Issue
Block a user