File tree 1 file changed +29
-0
lines changed
1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -332,6 +332,35 @@ mat23.fromTranslation = function (out, v) {
332
332
return out ;
333
333
} ;
334
334
335
+ /**
336
+ * Creates a matrix from a rotation, vector translation and vector scale
337
+ * This is equivalent to (but faster than):
338
+ *
339
+ * mat23.identity(dest);
340
+ * mat23.translate(dest, vec);
341
+ * let tmp = mat23.create();
342
+ * mat23.fromRotation(tmp, rot);
343
+ * mat23.multiply(dest, dest, tmp);
344
+ * mat23.fromScaling(tmp, scale);
345
+ * mat23.multiply(dest, dest, tmp);
346
+ *
347
+ * @param {mat23 } out mat23 receiving operation result
348
+ * @param {number } r Rotation radian
349
+ * @param {vec2 } v Translation vector
350
+ * @param {vec2 } s Scaling vector
351
+ * @returns {mat23 } out
352
+ */
353
+ mat23 . fromRTS = function ( out , r , t , s ) {
354
+ let sr = Math . sin ( r ) , cr = Math . cos ( r ) ;
355
+ out . m00 = cr * s . x ;
356
+ out . m01 = sr * s . x ;
357
+ out . m02 = - sr * s . y ;
358
+ out . m03 = cr * s . y ;
359
+ out . m04 = t . x ;
360
+ out . m05 = t . y ;
361
+ return out ;
362
+ } ;
363
+
335
364
/**
336
365
* Returns a string representation of a mat23
337
366
*
You can’t perform that action at this time.
0 commit comments