[as3] Updated noRotationOrReflection math

This commit is contained in:
badlogic 2016-10-19 14:19:17 +02:00
parent a80903ac14
commit fdbe5fdbde
4 changed files with 9 additions and 15 deletions

View File

@ -150,34 +150,28 @@ public class Bone implements Updatable {
break; break;
} }
case TransformMode.noRotationOrReflection: { case TransformMode.noRotationOrReflection: {
var psx:Number = Math.sqrt(pa * pa + pc * pc); s = pa * pa + pc * pc;
var psy:Number = 0;
var prx:Number = 0; var prx:Number = 0;
if (psx > 0.0001) { if (s > 0.0001) {
psy = Math.abs((pa * pd - pb * pc) / psx); s = Math.abs(pa * pd - pb * pc) / s;
pb = pc * s;
pd = pa * s;
prx = Math.atan2(pc, pa) * MathUtils.radDeg; prx = Math.atan2(pc, pa) * MathUtils.radDeg;
} else { } else {
psx = 0; pa = 0;
psy = Math.sqrt(pb * pb + pd * pd); pc = 0;
prx = 90 - Math.atan2(pd, pb) * MathUtils.radDeg; prx = 90 - Math.atan2(pd, pb) * MathUtils.radDeg;
} }
cos = MathUtils.cosDeg(prx);
sin = MathUtils.sinDeg(prx);
pa = cos * psx;
pb = -sin * psy;
pc = sin * psx;
pd = cos * psy;
var rx:Number = rotation + shearX - prx; var rx:Number = rotation + shearX - prx;
var ry:Number = rotation + shearY - prx + 90; var ry:Number = rotation + shearY - prx + 90;
la = MathUtils.cosDeg(rx) * scaleX; la = MathUtils.cosDeg(rx) * scaleX;
lb = MathUtils.cosDeg(ry) * scaleY; lb = MathUtils.cosDeg(ry) * scaleY;
lc = MathUtils.sinDeg(rx) * scaleX; lc = MathUtils.sinDeg(rx) * scaleX;
ld = MathUtils.sinDeg(ry) * scaleY; ld = MathUtils.sinDeg(ry) * scaleY;
_a = pa * la + pb * lc; _a = pa * la - pb * lc;
_b = pa * lb + pb * ld; _b = pa * lb - pb * ld;
_c = pc * la + pd * lc; _c = pc * la + pd * lc;
_d = pc * lb + pd * ld; _d = pc * lb + pd * ld;
break; break;
} }
case TransformMode.noScale: case TransformMode.noScale: