Published
Edited
Jan 26, 2021
5 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
bez_offset = function(bezier) {
const curve_cheb = bez3_to_cheb(bezier);
const [x, y] = curve_cheb;
const Dx = diff(x), Dy = diff(y);

return function bez_offset(p) {
const xp = chebeval(x, p), yp = chebeval(y, p);
const Dxp = chebeval(Dx, p), Dyp = chebeval(Dy, p);
// get the normal vector
const N = { x: -Dyp, y: Dxp, len: Math.sqrt(Dxp * Dxp + Dyp * Dyp) }
// unit normal vector
const uN = { x: N.x / N.len, y: N.y / N.len }
// offset vector
const oN = { x: uN.x * offset, y: uN.y * offset }
return [xp + oN.x, yp + oN.y];
}
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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