that = this,\r
bezier = function (x1, y1, x2, y2, x3, y3, x4, y4) {\r
return function (x) {\r
- var a = [x4-3*(x3-x2)-x1, 3*(x3-2*x2+x1), 3*(x2-x1), x1-x];\r
/*三次方程式の解から、ベジェ曲線のyを求める*/\r
- var s = Math.carda(a),\r
+ var s = Math.carda([x4-3*(x3-x2)-x1, 3*(x3-2*x2+x1), 3*(x2-x1), x1-x]),\r
i = 0,\r
si,\r
t = 0;\r
}\r
++i;\r
}\r
- console.log(t);\r
y = (y4-3*(y3-y2)-y1)*t*t*t + 3*(y3-2*y2+y1)*t*t + 3*(y2-y1)*t + y1;\r
- console.log(s, y);\r
return f(y);\r
};\r
},\r
}\r
} ).to = base("$from").$to;\r
\r
-/*ニュートン・ラフソン法により立方根(3乗根)を求める。Math.powだと負の値に対応していないため\r
+/*立方根(3乗根)を求める。Math.powだと負の値に対応していないため\r
* なお、ソースコードの著作権は Tomy氏が持っている(tomy@tk.airnet.ne.jp)\r
* http://www5.airnet.ne.jp/tomy/cpro/sslib3.htm*/\r
Math.cbrt = function (a) {\r
if(a == 0.) return 0.;\r
var w = Math.pow(Math.abs(a), 1./ 3.);\r
if(a < 0.) w = -w;\r
- return (w + 3. * a / (2. * w * w + a / w)) / 2.;\r
+ return w;\r
};\r
/*カルダノ法による三次方程式 a[0]x^3 + a[1]x^2 + a[2]x + a[3] の解を求める\r
* なお、ソースコードの著作権は Tomy氏が持っている\r
b = b(Math.random());\r
expect(Math.abs(calc.call()(b.x) - b.y.toFixed(10))).toBeLessThan(epsiron);\r
};\r
- ff([0, 0.5, 0.5, 1]);\r
+ for (var i=0;i<10000;++i) {\r
+ ff([0, 0.5, 0.5, 1]);\r
+ }\r
} );\r
/*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
it("should be this for the value (the invalid partion on a spline mode )", function() {\r