マトリックスの世界2:JavaScriptからイラストレーターに貼付けてある画像の拡大率と回転角度とシアー角度を得る

はやくも続編登場!!
というか、シアーかかっている場合にうまく角度が得られていなかったのを修正しました。
シアー角度も取得できるようになりました。
あとは反転してるかどうかの判定は微妙です。

var matrixConvert ={
'isObj' : function(obj){return typeof obj == 'object' ? true : false},
'hasMatrix' : function(obj){return obj.hasOwnProperty ('matrix') ? true : false},
'isMirrorX' : function(obj){
				if(!this.isObj(obj) || !this.hasMatrix(obj))return false;
				return obj.matrix.mValueA > 0 ? false : true;
				},
'isMirrorY' :function(obj){
                if(!this.isObj(obj) || !this.hasMatrix(obj))return false;
                return obj.matrix.mValueD < 0 ? false : (this.getRotation(obj) < -90 ? true : false);
                },
'getAllReal' : function(obj){
                if(!this.isObj(obj) || !this.hasMatrix(obj))return false;
                return {'hs' : this.getHorizontalScaleReal(obj),
                			'vs' : this.getVerticalScaleReal(obj),
                			'rotation' : this.getRotation(obj),
                		}	
              },
'getAll' : function(obj){
                if(!this.isObj(obj) || !this.hasMatrix(obj))return false;
                return {'hs' : this.getHorizontalScale(obj),
                			'vs' : this.getVerticalScale(obj),
                			'rotation' : this.getRotation(obj),
                			'tilt' : this.getTilt(obj)
                		}	
                },
'getScale' : function(obj){
                if(!this.isObj(obj) || !this.hasMatrix(obj))return false;
                return {'hs' : this.getHorizontalScale(obj),
                			'vs' : this.getVerticalScale(obj)
                		}
                },
'getHorizontalScaleReal' : function(obj){
                if(!this.isObj(obj) || !this.hasMatrix(obj))return false;
                return Math.sqrt(Math.pow(obj.matrix.mValueA,2) + Math.pow(obj.matrix.mValueB,2));
},
'getHorizontalScale' : function(obj){
                if(!this.isObj(obj) || !this.hasMatrix(obj))return false;
                return Math.round(this.getHorizontalScaleReal(obj)*100000)/1000;
                },
'getVerticalScaleReal' : function(obj){
                if(!this.isObj(obj) || !this.hasMatrix(obj))return false;
                return Math.sqrt(Math.pow(obj.matrix.mValueC,2) + Math.pow(obj.matrix.mValueD,2));
},
'getVerticalScale' : function(obj){
                if(!this.isObj(obj) || !this.hasMatrix(obj))return false;
                return Math.round(this.getVerticalScaleReal(obj)*100000)/1000;
                },
'getRotationX' : function(obj){
                if(!this.isObj(obj) || !this.hasMatrix(obj))return false;
                return Math.atan2(obj.matrix.mValueB, obj.matrix.mValueA)*180/Math.PI;
                },
'getRotationY' : function(obj){
                if(!this.isObj(obj) || !this.hasMatrix(obj))return false;
                return Math.atan2(obj.matrix.mValueC, obj.matrix.mValueD)*180/Math.PI;
                },
'getRotation' : function(obj){
                if(!this.isObj(obj) || !this.hasMatrix(obj))return false;
                var r = Math.round(this.getRotationX(obj)*1000)/1000;
                //var r = Math.round(this.getRotationY(obj)*1000)/1000;
                if(obj.constructor.name == 'PlacedItem')return r;
                if(obj.constructor.name == 'TextFrame' || obj.constructor.name == 'RasterItem')return  r;
                if(obj.constructor.name == 'PatternColor' || obj.constructor.name == 'GradientColor')return r*-1;
                return false;
                },
'getTilt' : function(obj){
                if(!this.isObj(obj) || !this.hasMatrix(obj))return false;
                    var rY = Math.round(this.getRotationY(obj)*1000)/1000;
                    var rX = Math.round(this.getRotationX(obj)*1000)/1000;
                    var total = rX + rY;
                    var tilt = total > 0 ? total - 180 : total + 180;
                    return tilt;
                }
}

使い方

OBJECT = app.activeDocument.selection[0];
//シアーの角度(水平方向)を得る
matrixConvert.getTilt(OBJECT);
//回転角度
matrixConvert.getRotation(OBJECT);
//拡大率(X)
matrixConvert.getHorizontalScale(OBJECT);
//拡大率(Y)
matrixConvert.getVerticalScale(OBJECT);
//全部
var all = matrixConvert.getAll(OBJECT);
alert("拡大率(X):"+ all['hs']); 
alert("拡大率(Y):"+ all['vs']);
alert("回転角度:"+ all['rotation']);
alert("シアー角度(水平):"+ all['tilt']);

Matrix - ActionScript 3.0 コンポーネントリファレンスガイドをながめながら朧げながら概要がつかめてきました。