Skip to content

Commit

Permalink
Minor change: Only compute bl and cl when needed. #125
Browse files Browse the repository at this point in the history
  • Loading branch information
martinfrances107 authored and Fil committed Apr 21, 2021
1 parent 8618009 commit 4e33937
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/voronoi.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ export default class Voronoi {
const dy = y2 - y1;
const ex = x3 - x1;
const ey = y3 - y1;
const bl = dx * dx + dy * dy;
const cl = ex * ex + ey * ey;
const ab = (dx * ey - dy * ex) * 2;

if (Math.abs(ab) < 1e-9) {
Expand All @@ -56,6 +54,8 @@ export default class Voronoi {
y = (y1 + y3) / 2 + a * ex;
} else {
const d = 1 / ab;
const bl = dx * dx + dy * dy;
const cl = ex * ex + ey * ey;
x = x1 + (ey * bl - dy * cl) * d;
y = y1 + (dx * cl - ex * bl) * d;
}
Expand Down

0 comments on commit 4e33937

Please sign in to comment.