Published
Edited
Jan 9, 2019
1 fork
20 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
curvature_transformation = (k) => 400*Math.atan(50*k)/Math.PI
Insert cell
Insert cell
curvature_comb = function(bezier) {
const curve_cheb = bez3_to_cheb(bezier);
const [x, y] = curve_cheb;
const Dx = diff(x), Dy = diff(y);
const DDx = diff(Dx), DDy = diff(Dy);

return function curvature_comb(p) {
const xp = chebeval(x, p), yp = chebeval(y, p);
const Dxp = chebeval(Dx, p), Dyp = chebeval(Dy, p);
const DDxp = chebeval(DDx, p), DDyp = chebeval(DDy, p);
const Ds_inv = 1 / Math.sqrt(Dxp*Dxp + Dyp*Dyp);
const curvature = (Dxp*DDyp - Dyp*DDxp) * (Ds_inv*Ds_inv*Ds_inv);
const squished_curvature = Ds_inv * curvature_transformation(curvature);
// const squished_curvature = Ds_inv * curvature * 2000;
// return Dx * squished_curvature
return [xp + squished_curvature * Dyp, yp - squished_curvature * Dxp];
}
}
Insert cell
viewof bez = new View([[489,287],[739,68],[197,222],[534,350]])
Insert cell
import {bez3_to_cheb} from '@jrus/bezier-segment-arclength'
Insert cell
import {evaluate as chebeval, diff, cumsum, sum, coeffs2vals, vals2coeffs, chebpts} from "@jrus/cheb"
Insert cell
import {bezeval, bezpts_to_svgpath} from "@jrus/bezplot"
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