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

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