Published
Edited
Jan 29, 2018
3 forks
Importers
25 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function distance([x1, y1], [x2, y2]) {
return Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2);
}
Insert cell
function interpolate([x1, y1], [x2, y2], t) {
return [x1 + (x2 - x1) * t, y1 + (y2 - y1) * t];
}
Insert cell
function project([x1, y1], [x2, y2], [x3, y3]) {
const x21 = x2 - x1, y21 = y2 - y1;
const x31 = x3 - x1, y31 = y3 - y1;
return (x31 * x21 + y31 * y21) / (x21 * x21 + y21 * y21);
}
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more