thelonious / kld-polynomial Goto Github PK
View Code? Open in Web Editor NEWA class of simple polynomial functionality including root finding
License: BSD 3-Clause "New" or "Revised" License
A class of simple polynomial functionality including root finding
License: BSD 3-Clause "New" or "Revised" License
I subdivided a cubic bezier and created the two following cubic beziers:
const a = [
{ x: 162.48848597698444, y: 112.35319657757165 },
{ x: 163.95162031178776, y: 116.41373265436673 },
{ x: 165.52010700334841, y: 120.60494234401577 },
{ x: 167.20635691757136, y: 124.93096260181979 },
];
const b = [
{ x: 167.20635691757136, y: 124.93096260181979 },
{ x: 171.54020965581395, y: 136.04932328005688 },
{ x: 176.651945072729, y: 148.0581725463195 },
{ x: 182.75226034297538, y: 161.02774279216203 },
];
Running these beziers through intersectBezier3Bezier3
will produce this Polynomial.
var poly = new Polynomial(
8.282089296964086e-38,
1.3395768780405303e-26,
7.222276683850399e-16,
1.4410533333746558e-14,
1.4180955129790285e-13,
4.0776756971006023e-13,
-1.3752193828153736e-13,
-7.466249840604178e-14,
-6.794564910705958e-14,
-4.551914400963142e-15,
);
Calling poly.simplify()
will result in a polynomial with the coefs being an empty array.
I'm not going to pretend to understand the math behind Polynomials, but in 61e809c, an empty Polynomial is referred to as unexpected. What makes an empty Polynomial unexpected?
I consistently run into this issue when intersecting different beziers that are the result of a bezier subdivision, but haven't seen this happen under any other circumstances.
My current workaround this issue is:
var droots = this.getDegree() > 0
? deriv.getRootsInInterval(min, max)
: [];
https://npmjs.org/doc/misc/npm-disputes.html
Don't squat on package names. Publish code or move out of the way.
Putting empty packages in the registry. Packages must have SOME functionality. It can be silly, but it can't be nothing. (See also: squatting.)
I was wondering why result is here:
kld-polynomial/lib/Polynomial.js
Line 38 in c70584e
svg-intersections depends on zeroErrorEstimate and it's not in the version there.
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.