@@ -238,10 +238,9 @@ var TransformMatrix = new Class({
238238 } ,
239239
240240 /**
241- * The rotation of the Matrix, normalized to be within the Phaser right-handed
242- * clockwise rotation space. Value is in radians.
241+ * The rotation of the Matrix. Value is in radians.
243242 *
244- * @name Phaser.GameObjects.Components.TransformMatrix#rotationNormalized
243+ * @name Phaser.GameObjects.Components.TransformMatrix#rotation
245244 * @type {number }
246245 * @readonly
247246 * @since 3.4.0
@@ -250,10 +249,24 @@ var TransformMatrix = new Class({
250249
251250 get : function ( )
252251 {
253- // Previous version:
254- // return Math.acos(this.a / this.scaleX) * (Math.atan(-this.c / this.a) < 0 ? -1 : 1);
252+ return Math . acos ( this . a / this . scaleX ) * ( Math . atan ( - this . c / this . a ) < 0 ? - 1 : 1 ) ;
253+ }
254+
255+ } ,
256+
257+ /**
258+ * The rotation of the Matrix, normalized to be within the Phaser right-handed
259+ * clockwise rotation space. Value is in radians.
260+ *
261+ * @name Phaser.GameObjects.Components.TransformMatrix#rotationNormalized
262+ * @type {number }
263+ * @readonly
264+ * @since 3.19.0
265+ */
266+ rotationNormalized : {
255267
256- // Normalized version:
268+ get : function ( )
269+ {
257270 var matrix = this . matrix ;
258271
259272 var a = matrix [ 0 ] ;
@@ -293,7 +306,26 @@ var TransformMatrix = new Class({
293306
294307 get : function ( )
295308 {
296- return Math . sqrt ( ( this . a * this . a ) + ( this . c * this . c ) ) ;
309+ var matrix = this . matrix ;
310+ var a = matrix [ 0 ] ;
311+ var b = matrix [ 1 ] ;
312+ var c = matrix [ 2 ] ;
313+ var d = matrix [ 3 ] ;
314+
315+ var determ = a * d - b * c ;
316+
317+ if ( a || b )
318+ {
319+ return determ / Math . sqrt ( a * a + b * b ) ;
320+ }
321+ else if ( c || d )
322+ {
323+ return Math . sqrt ( c * c + d * d ) ;
324+ }
325+ else
326+ {
327+ return 0 ;
328+ }
297329 }
298330
299331 } ,
@@ -310,7 +342,26 @@ var TransformMatrix = new Class({
310342
311343 get : function ( )
312344 {
313- return Math . sqrt ( ( this . b * this . b ) + ( this . d * this . d ) ) ;
345+ var matrix = this . matrix ;
346+ var a = matrix [ 0 ] ;
347+ var b = matrix [ 1 ] ;
348+ var c = matrix [ 2 ] ;
349+ var d = matrix [ 3 ] ;
350+
351+ var determ = a * d - b * c ;
352+
353+ if ( a || b )
354+ {
355+ return Math . sqrt ( a * a + b * b ) ;
356+ }
357+ else if ( c || d )
358+ {
359+ return determ / Math . sqrt ( c * c + d * d ) ;
360+ }
361+ else
362+ {
363+ return 0 ;
364+ }
314365 }
315366
316367 } ,
0 commit comments