Public
Edited
Nov 1, 2020
Insert cell
md`# Affine transformations preserving a parabola
`
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
cy = 5
Insert cell
{
const ct = canvas.ct;

ct.save();
ct.clearRect(0, 0, WIDTH, HEIGHT);
ct.translate(cx, HEIGHT - cy);
ct.transform(50, 0, 0, -50, 0, 0);
ct.transform(1, 2*t, 0, 1, t, t*t);
const max_x = Math.floor((WIDTH - cx) / 50);
const max_y = Math.floor((HEIGHT - cy) / 50);

ct.beginPath();
for (let y = -max_y; y <= max_y * 2; y++) {
ct.moveTo(-max_x-1, y);
ct.lineTo(max_x+1, y);
}
for (let x = -max_x; x <= max_x; x++) {
ct.moveTo(x, -max_y);
ct.lineTo(x, max_y * 2);
}
ct.lineWidth = 1/50;
ct.strokeStyle = "#999";
ct.stroke();
ct.beginPath();
ct.moveTo(-Math.sqrt(max_y * 2), max_y * 2);
ct.quadraticCurveTo(0, -max_y * 2, Math.sqrt(max_y * 2), max_y * 2);
ct.lineWidth = 3/50;
ct.strokeStyle = "red";
ct.stroke();
ct.restore();
return this || html`(<i>the drawing function</i>)`;
}
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more