(pts, angle)
| 1134 | }; |
| 1135 | |
| 1136 | const simplify = (pts, angle) => { |
| 1137 | angle = angle || 0; |
| 1138 | let num = 0; |
| 1139 | for (let i = pts.length - 1; pts.length > 3 && i >= 0; --i) { |
| 1140 | if (collinear(at(pts, i - 1), at(pts, i), at(pts, i + 1), angle)) { |
| 1141 | pts.splice(i % pts.length, 1); // Remove middle point |
| 1142 | num++; |
| 1143 | } |
| 1144 | } |
| 1145 | return num; |
| 1146 | }; |
| 1147 | |
| 1148 | const collinear = (a, b, c, thresholdAngle) => { |
| 1149 | if (!thresholdAngle) { |
no test coverage detected