1
0
mirror of https://github.com/Pomax/BezierInfo-2.git synced 2025-09-02 04:42:43 +02:00
This commit is contained in:
Pomax
2020-08-16 09:34:24 -07:00
parent b989e5b810
commit 837fdbe187
2 changed files with 53 additions and 2 deletions

View File

@@ -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:
<Graphic title="Quadratic Bézier curve extremities" setup={this.setupQuadratic} draw={this.draw}/>
<Graphic title="Cubic Bézier curve extremities" setup={this.setupCubic} draw={this.draw}/>
<graphics-element title="Quadratic Bézier curve extremities" width="825" src="./quadratic.js"></graphics-element>
<graphics-element title="Cubic Bézier curve extremities" width="825" src="./cubic.js"></graphics-element>

View File

@@ -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();
}