OSDN Git Service

Modify the Math._newton function
authordhrname <dhrname@users.sourceforge.jp>
Sat, 27 Jun 2015 14:41:56 +0000 (23:41 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Sat, 27 Jun 2015 14:41:56 +0000 (23:41 +0900)
org/w3c/dom/smil.js
tool/Spec/spec/SvgDomSpec.js

index 539e2c3..cf8313d 100644 (file)
@@ -642,12 +642,11 @@ base("$from").of( {
            By = 3*(y3-2*y2),\r
            Cy = 3*y2,\r
            _newton = Math.qubicnewton; //高速化のためのエイリアス\r
-       if ((x2 === 1) && (y2 === 0)\r
-            && (x2 === 0) && (y2 === 1)) {\r
+       if ((x2 === 0) && (y2 === 0)\r
+            && (x3 === 1) && (y3 === 1)) {\r
               /*linearモードと同じ効果*/\r
-              return function(x) {\r
-                return f(x);\r
-              };\r
+              this.to.call();\r
+              return f;\r
        }\r
        var tkey = this.keyTime;\r
        if (tkey || isFinite(tkey) ) {\r
@@ -692,12 +691,14 @@ Math.qubicnewton = function(a0, a1, a2, a3, b) {
   }\r
   /*限界の収束回数は100回とする*/\r
   for (var i=0;i<100;++i) {\r
-    if ((fb < eps) && (fb > -eps)) {\r
+    /*数値nは与えられた三次方程式を微分したもの*/\r
+    var n = 3* a0 *b*b + 2 * a1 *b + a2;\r
+    if (!n || ( (fb < eps) && (fb > -eps) )) {\r
       fb = eps = void 0;\r
       return b;\r
     } else {\r
-      /*以下は収束の漸化式。分母は与えられた三次方程式を微分したもの*/\r
-      b =  b - fb / (3* a0 *b*b + 2 * a1 *b + a2);\r
+      /*以下は収束の漸化式*/\r
+      b =  b - fb / n;\r
       fb = a0 *b*b*b + a1 *b*b + a2*b + a3;\r
     }\r
   }\r
index 2806544..e41536f 100644 (file)
@@ -3916,6 +3916,19 @@ describe("SMIL Animation Spec", function() {
           f(216, "10.0");\r
           f(300, "10.0");\r
           \r
+          frame.timelines.length = 0;\r
+          ele.setAttributeNS(null, "calcMode", "spline");\r
+          ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");\r
+          ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");\r
+          ele.setAttributeNS(null, "dur", "8s");\r
+          ele.setAttributeNS(null, "values", "300;255;180;30");\r
+          $animate.init(ele);\r
+          f(0, "300.0");\r
+          f(48, "255.0");\r
+          f(96, "180.0");\r
+          f(192, "30.0");\r
+          f(300, "30.0");\r
+          \r
         } );\r
         /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
         it("should be this for the value (the invalid partion )", function() {\r