1
0
mirror of https://github.com/Pomax/BezierInfo-2.git synced 2025-08-20 07:21:43 +02:00

code comments

This commit is contained in:
Pomax
2020-09-19 22:51:19 -07:00
parent 4c0e71cd4a
commit d77d3649b6
27 changed files with 97 additions and 61 deletions

View File

@@ -23,12 +23,15 @@ draw() {
this.drawLine(...line);
// To find our intersections, we align the curve to our line,
// so that all we need to do now is find the roots for the curve.
const [p1, p2] = line;
const aligned = utils.align(curve.points, {p1,p2});
const nB = new Bezier(this, aligned);
const roots = utils.roots(nB.points);
const coords = roots.map(t => curve.get(t));
// done: any roots we find are intersections on our original curve.
if (roots.length) {
roots.forEach((t,i) => {
var p = coords[i];