diff --git a/chapters/extremities/content.en-GB.md b/chapters/extremities/content.en-GB.md index a5327f0f..982b5dec 100644 --- a/chapters/extremities/content.en-GB.md +++ b/chapters/extremities/content.en-GB.md @@ -194,5 +194,5 @@ As it turns out, Newton-Raphson is so blindingly fast, so we could get away with So now that we know how to do root finding, we can determine the first and second derivative roots for our Bézier curves, and show those roots overlaid on the previous graphics: - - + + diff --git a/chapters/extremities/quadratic.js b/chapters/extremities/quadratic.js new file mode 100644 index 00000000..d4f4a27c --- /dev/null +++ b/chapters/extremities/quadratic.js @@ -0,0 +1,51 @@ +setup() { + this.curve = Bezier.defaultQuadratic(this); + setMovable(this.curve.points); +} + +draw() { + resetTransform(); + clear(); + const dim = this.height; + const curve = this.curve; + curve.drawSkeleton(); + curve.drawCurve(); + curve.drawPoints(); + + translate(dim, 0); + setStroke(`black`); + line(0,0,0,dim); + + scale(0.8, 0.9); + translate(40,20); + drawAxes(`t`, 0, 1, `X`, 0, dim, dim, dim); + + plot(new Bezier(this, curve.points.map((p,i) => ({ + x: (i/2) * dim, + y: p.x + })))); + + resetTransform(); + translate(2*dim, 0); + setStroke(`black`); + line(0,0,0,dim); + + scale(0.8, 0.9); + translate(40,20); + drawAxes(`t`, 0,1, `Y`, 0, dim, dim, dim); + + plot(new Bezier(this, curve.points.map((p,i) => ({ + x: (i/2) * dim, + y: p.y + })))) +} + +plot(dimension) { + dimension.drawCurve(); + +} + + +onMouseMove() { + redraw(); +}