Skip to content

Commit

Permalink
fix(geom-splines): fix seg count in cubicFromArc(), minor optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Jul 30, 2019
1 parent 0e751b5 commit e289ade
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/geom-splines/src/cubic-arc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ export const cubicFromArc = (
};

const res: Vec[][] = [];
const n = Math.max(roundEps(Math.abs(delta) / HALF_PI, 1e-3), 1);
const n = Math.ceil(roundEps(Math.abs(delta) / HALF_PI, 1e-3));
const d = delta / n;
const t = (8 / 6) * Math.tan(0.25 * d);
if (!isFinite(t)) {
return [cubicFromLine(p, q)];
}
for (let i = n, theta = start; i > 0; i--, theta += d) {
const [s1, c1] = sincos(theta);
const [s2, c2] = sincos(theta + d);
for (let i = n, theta = start, sc = sincos(theta); i > 0; i--, theta += d) {
const [s1, c1] = sc;
const [s2, c2] = (sc = sincos(theta + d));
res.push([
mapP(c1, s1),
mapP(c1 - s1 * t, s1 + c1 * t),
Expand Down

0 comments on commit e289ade

Please sign in to comment.