1
0
mirror of https://github.com/Pomax/BezierInfo-2.git synced 2025-09-27 00:29:00 +02:00

curvature

This commit is contained in:
Pomax
2020-08-27 14:59:08 -07:00
parent 0730e3dda4
commit 17d71c7d70
22 changed files with 265 additions and 249 deletions

View File

@@ -647,11 +647,7 @@ const utils = {
return [];
},
curvature: function (t, points, _3d, kOnly) {
const dpoints = utils.derive(points);
const d1 = dpoints[0];
const d2 = dpoints[1];
curvature: function (t, d1, d2, _3d, kOnly) {
let num,
dnm,
adk,
@@ -705,8 +701,8 @@ const utils = {
if (!kOnly) {
// compute k'(t) based on the interval before, and after it,
// to at least try to not introduce forward/backward pass bias.
const pk = utils.curvature(t - 0.001, points, _3d, true).k;
const nk = utils.curvature(t + 0.001, points, _3d, true).k;
const pk = utils.curvature(t - 0.001, d1, d2, _3d, true).k;
const nk = utils.curvature(t + 0.001, d1, d2, _3d, true).k;
dk = (nk - k + (k - pk)) / 2;
adk = (abs(nk - k) + abs(k - pk)) / 2;
}