//>>built
define("dojox/gfx/decompose",["./_base","dojo/_base/lang","./matrix"],function(t,m,h){function k(a,b){return Math.abs(a-b)<=1E-6*(Math.abs(a)+Math.abs(b))}function l(a,b,d,c){if(!isFinite(a))return d;if(!isFinite(d))return a;b=Math.abs(b);c=Math.abs(c);return(b*a+c*d)/(b+c)}function n(a){a=h.normalize(a);var b=-a.xx-a.yy,d=a.xx*a.yy-a.xy*a.yx,c=Math.sqrt(b*b-4*d);b=-(b+(0>b?-c:c))/2;d/=b;c=a.xy/(b-a.xx);var f=1,e=a.xy/(d-a.xx),g=1;k(b,d)&&(c=1,e=f=0,g=1);isFinite(c)||(c=1,f=(b-a.xx)/a.xy,isFinite(f)||
(c=(b-a.yy)/a.yx,f=1,isFinite(c)||(c=1,f=a.yx/(b-a.yy))));isFinite(e)||(e=1,g=(d-a.xx)/a.xy,isFinite(g)||(e=(d-a.yy)/a.yx,g=1,isFinite(e)||(e=1,g=a.yx/(d-a.yy))));a=Math.sqrt(c*c+f*f);var p=Math.sqrt(e*e+g*g);isFinite(c/=a)||(c=0);isFinite(f/=a)||(f=0);isFinite(e/=p)||(e=0);isFinite(g/=p)||(g=0);return{value1:b,value2:d,vector1:{x:c,y:f},vector2:{x:e,y:g}}}function q(a,b){var d=0>a.xx*a.yy||0<a.xy*a.yx?-1:1,c=b.angle1=(Math.atan2(a.yx,a.yy)+Math.atan2(-d*a.xy,d*a.xx))/2;d=Math.cos(c);c=Math.sin(c);
b.sx=l(a.xx/d,d,-a.xy/c,c);b.sy=l(a.yy/d,d,a.yx/c,c);return b}function r(a,b){var d=0>a.xx*a.yy||0<a.xy*a.yx?-1:1,c=b.angle2=(Math.atan2(d*a.yx,d*a.xx)+Math.atan2(-a.xy,a.yy))/2;d=Math.cos(c);c=Math.sin(c);b.sx=l(a.xx/d,d,a.yx/c,c);b.sy=l(a.yy/d,d,-a.xy/c,c);return b}return t.decompose=function(a){var b=h.normalize(a);a={dx:b.dx,dy:b.dy,sx:1,sy:1,angle1:0,angle2:0};if(k(b.xy,0)&&k(b.yx,0))return m.mixin(a,{sx:b.xx,sy:b.yy});if(k(b.xx*b.yx,-b.xy*b.yy))return q(b,a);if(k(b.xx*b.xy,-b.yx*b.yy))return r(b,
a);var d=new h.Matrix2D(b);var c=m.mixin(d,{dx:0,dy:0,xy:d.yx,yx:d.xy});d=n([b,c]);c=n([c,b]);d=new h.Matrix2D({xx:d.vector1.x,xy:d.vector2.x,yx:d.vector1.y,yy:d.vector2.y});c=new h.Matrix2D({xx:c.vector1.x,xy:c.vector1.y,yx:c.vector2.x,yy:c.vector2.y});b=new h.Matrix2D([h.invert(d),b,h.invert(c)]);q(c,a);b.xx*=a.sx;b.yy*=a.sy;r(d,a);b.xx*=a.sx;b.yy*=a.sy;return m.mixin(a,{sx:b.xx,sy:b.yy})}});