OSDN Git Service

getTotalLengthメソッドで、3次ベジェ曲線の不正確な計算があったので削除
authordhrname <dhrname@users.sourceforge.jp>
Thu, 30 Aug 2012 13:51:30 +0000 (22:51 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Thu, 30 Aug 2012 13:51:30 +0000 (22:51 +0900)
org/w3c/dom/svg.js

index 8610f2b..0bb36d1 100644 (file)
@@ -3111,19 +3111,6 @@ _sproto._com = {
         var ps = nl.getItem(i-1);
         s += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
       } else if (seg.pathSegType === /*SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS*/ 6) {
-        var ps = nl.getItem(i-1), dd = 0;
-        /*2点のハンドルを結んだ線分の3辺と、
-         *セグメントの始点と終点を結んだ1辺を足して2で割ったものを、ベジェ曲線の距離の近似値とする
-         *
-         *注意
-         *本来は積分とシンプソン法などの解析を使って、媒介曲線であるベジェ曲線の距離を割り出すのが、
-         *精密であり望ましいが、ここでは時間がかかりすぎるので別の方法をとる
-         */
-        dd += _math.sqrt(_math.pow((seg.x1-ps.x), 2) + _math.pow((seg.y1-ps.y), 2));
-        dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
-        dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
-        dd += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
-        s += dd / 2;
       } else if (seg.pathSegType === /*SVGPathSeg.PATHSEG_CLOSEPATH*/ 1) {
         var ps = nl.getItem(i-1), ms = nl.getItem(0);
         s += _math.sqrt(_math.pow((ps.x-ms.x), 2) + _math.pow((ps.y-ms.y), 2));