{
randomize;
const inputs = [randVec(), randVec(), randVec(), randVec(), randVec()];
const curve = new spline.CurveToQuadraticBeziers();
curve.init(
inputs[0],
inputs[0],
inputs[1]
);
const controlPoints = [];
let { q01, q02, q11, q12 } = curve.point(inputs[2]);
controlPoints.push(q01, q01, q02, q11, q12);
({ q01, q02, q11, q12 } = curve.point(inputs[3]));
controlPoints.push(q01, q02, q11, q12);
({ q01, q02, q11, q12 } = curve.point(inputs[4]));
controlPoints.push(q01, q02, q11, q12);
({ q01, q02, q11, q12 } = curve.point(inputs[4]));
controlPoints.push(q01, q02, q11, q12);
return Plot.plot({
marks: [
Plot.line(controlPoints, { x: "x", y: "y", stroke: "#f003" }),
,
new QuadraticCurves(controlPoints, { x: "x", y: "y" }),
Plot.dot(controlPoints, { x: "x", y: "y", fill: "#f66", r: 2 }),
Plot.dot(inputs, { x: "x", y: "y", fill: "#000", r: 4 })
],
axis: null,
margin: 10
});
}