this.keyTime = this.to.distance(this.to.from) / this.norm;\r
return f;\r
} else if (this.mode === "spline") {\r
- var x = 0,\r
- y = 0,\r
- bezier = function (x1, y1, x2, y2, x3, y3, x4, y4) {\r
- return function (t) {\r
- x = (x4-3*(x3+x2)-x1)*t*t*t + 3*(x3-2*x2+x1)*t*t + 3*(x2-x1)*t + x1;\r
- y = (y4-3*(y3+y2)-y1)*t*t*t + 3*(y3-2*y2+y1)*t*t + 3*(y2-y1)*t + y1;\r
- return y+"";\r
- };\r
- },\r
- tk = this.keySplines;\r
+ this.to.call();\r
+ var x = 0,\r
+ y = 0,\r
+ that = this,\r
+ bezier = function (x1, y1, x2, y2, x3, y3, x4, y4) {\r
+ return function (t) {\r
+ x = (x4-3*(x3+x2)-x1)*t*t*t + 3*(x3-2*x2+x1)*t*t + 3*(x2-x1)*t + x1;\r
+ y = (y4-3*(y3+y2)-y1)*t*t*t + 3*(y3-2*y2+y1)*t*t + 3*(y2-y1)*t + y1;\r
+ return f(y);\r
+ };\r
+ },\r
+ tk = this.keySplines;\r
return bezier(0, 0, tk[0], tk[1], tk[2], tk[3], 1, 1);\r
} else if (this.mode === "discrete") {\r
return function (t) {\r
calc.mode = "discrete";\r
expect(calc.call()()).toEqual(calc.string);\r
} );\r
+ \r
/*splineモードの境界条件を調べておく (limit value analysis)*/\r
it("should be this for the value (spline mode limit value analysis)", function() {\r
/*3次ベジェ曲線の数式はこのページを参考にした http://geom.web.fc2.com/geometry/bezier/cubic.html*/\r
};\r
expect(calc.keySplines).toBeNull();\r
calc.mode = "spline";\r
+ expect( function() {\r
+ calc.call();\r
+ }).toThrow();\r
calc.keySplines = [0, 0, 1, 1];\r
- expect(calc.call()(0)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(0)+"");\r
- expect(calc.call()(1)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(1)+"");\r
+ calc.to.degit = 1;\r
+ calc.to.from = from;\r
+ expect(calc.call()(0)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(0)+".0");\r
+ calc.to.from = from;\r
+ expect(calc.call()(1)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(1)+".0");\r
+ calc.to.from = from;\r
+ expect(calc.call()(0.5)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(0.5)+"");\r
} );\r
/*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
it("should be this for the value (the valid partion on a spline mode )", function() {\r
+ var x = 0,\r
+ y = 0,\r
+ bezier = function (x1, y1, x2, y2, x3, y3, x4, y4) {\r
+ return function (t) {\r
+ x = (x4-3*(x3+x2)-x1)*t*t*t + 3*(x3-2*x2+x1)*t*t + 3*(x2-x1)*t + x1;\r
+ y = (y4-3*(y3+y2)-y1)*t*t*t + 3*(y3-2*y2+y1)*t*t + 3*(y2-y1)*t + y1;\r
+ return y;\r
+ };\r
+ };\r
+ calc.mode = "spline";\r
+ calc.keySplines = [0, 0.5, 0.5, 1];\r
+ calc.to.degit = 1;\r
+ expect(calc.call()(0)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(0)+".0");\r
+ calc.to.from = from;\r
+ expect(calc.call()(1)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(1)+".0");\r
+ calc.to.from = from;\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