mirror of
https://github.com/Pomax/BezierInfo-2.git
synced 2025-03-14 19:29:51 +01:00
cardano fix
This commit is contained in:
parent
ffb21996a1
commit
5d1ff414d9
File diff suppressed because one or more lines are too long
@ -87,26 +87,49 @@ function accept(t) {
|
||||
}
|
||||
|
||||
// A real-cuberoots-only function:
|
||||
function crt(v) {
|
||||
if(v<0) return -Math.pow(-v,1/3);
|
||||
return Math.pow(v,1/3);
|
||||
function cuberoot(v) {
|
||||
if(v<0) return -pow(-v,1/3);
|
||||
return pow(v,1/3);
|
||||
}
|
||||
|
||||
// Now then: given cubic coordinates {pa, pb, pc, pd} find all roots.
|
||||
function getCubicRoots(pa, pb, pc, pd) {
|
||||
var d = (-pa + 3*pb - 3*pc + pd),
|
||||
a = (3*pa - 6*pb + 3*pc) / d,
|
||||
b = (-3*pa + 3*pb) / d,
|
||||
c = pa / d;
|
||||
var a = (3*pa - 6*pb + 3*pc),
|
||||
b = (-3*pa + 3*pb),
|
||||
c = pa,
|
||||
d = (-pa + 3*pb - 3*pc + pd);
|
||||
|
||||
// do a check to see whether we even need cubic solving:
|
||||
if (approximately(d,0)) {
|
||||
// this is not a cubic curve.
|
||||
if (approximately(a,0)) {
|
||||
// in fact, this is not a quadratic curve either.
|
||||
if (approximately(b,0)) {
|
||||
// in fact in fact, there are no solutions.
|
||||
return [];
|
||||
}
|
||||
// linear solution
|
||||
return [-c / b].filter(accept);
|
||||
}
|
||||
// quadratic solution
|
||||
var q = sqrt(b*b - 4*a*c), 2a = 2*a;
|
||||
return [(q-b)/2a, (-b-q)/2a].filter(accept)
|
||||
}
|
||||
|
||||
// at this point, we know we need a cubic solution.
|
||||
|
||||
a /= d;
|
||||
b /= d;
|
||||
c /= d;
|
||||
|
||||
var p = (3*b - a*a)/3,
|
||||
p3 = p/3,
|
||||
q = (2*a*a*a - 9*a*b + 27*c)/27,
|
||||
q2 = q/2,
|
||||
discriminant = q2*q2 + p3*p3*p3;
|
||||
p3 = p/3,
|
||||
q = (2*a*a*a - 9*a*b + 27*c)/27,
|
||||
q2 = q/2,
|
||||
discriminant = q2*q2 + p3*p3*p3;
|
||||
|
||||
// and some variables we're going to use later on:
|
||||
var u1,v1,root1,root2,root3;
|
||||
var u1, v1, root1, root2, root3;
|
||||
|
||||
// three possible real roots:
|
||||
if (discriminant < 0) {
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
6
package-lock.json
generated
6
package-lock.json
generated
@ -2500,9 +2500,9 @@
|
||||
}
|
||||
},
|
||||
"bezier-js": {
|
||||
"version": "2.2.5",
|
||||
"resolved": "https://registry.npmjs.org/bezier-js/-/bezier-js-2.2.5.tgz",
|
||||
"integrity": "sha512-HGh+GevPguxrAmnWF2/A+8c8FEatnKcE6WttpYWA5fn1CfpJz4reFbr11DuyFs2gwaIo9vF7aVXW2xg1iaqvyg==",
|
||||
"version": "2.2.6",
|
||||
"resolved": "https://registry.npmjs.org/bezier-js/-/bezier-js-2.2.6.tgz",
|
||||
"integrity": "sha512-06pp5NflWADL+PCqEH+YsWsdnd5R5p6asXZjO+kPgII0vsGPnHRhL1Tpg+Iqka2YXOGJR9WrqGWsf7Kh7uiCmA==",
|
||||
"dev": true
|
||||
},
|
||||
"big.js": {
|
||||
|
@ -53,7 +53,7 @@
|
||||
"babel-preset-es2015": "^6.3.13",
|
||||
"babel-preset-react": "^6.3.13",
|
||||
"babel-register": "^6.4.3",
|
||||
"bezier-js": "^2.0.0",
|
||||
"bezier-js": "^2.2.6",
|
||||
"block-loader": "^2.0.0",
|
||||
"chroma-js": "^1.1.1",
|
||||
"cross-env": "^3.1.4",
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user