fromRotationTranslationScale function
Creates a matrix from a quaternion rotation, vector translation and vector scale This is equivalent to (but much faster than):
mat4.identity(dest);
mat4.translate(dest, vec);
final quatMat = mat4.create();
quat4.toMat4(quat, quatMat);
mat4.multiply(dest, quatMat);
mat4.scale(dest, scale)
@param {mat4} out mat4 receiving operation result @param {quat4} q Rotation quaternion @param {ReadonlyVec3} v Translation vector @param {ReadonlyVec3} s Scaling vector @returns {mat4} out
Implementation
List<double> fromRotationTranslationScale(List<double> out, List<double> q, List<double> v, List<double> s) {
// Quaternion math
final x = q[0], y = q[1], z = q[2], w = q[3];
final x2 = x + x;
final y2 = y + y;
final z2 = z + z;
final xx = x * x2;
final xy = x * y2;
final xz = x * z2;
final yy = y * y2;
final yz = y * z2;
final zz = z * z2;
final wx = w * x2;
final wy = w * y2;
final wz = w * z2;
final sx = s[0];
final sy = s[1];
final sz = s[2];
out[0] = (1 - (yy + zz)) * sx;
out[1] = (xy + wz) * sx;
out[2] = (xz - wy) * sx;
out[3] = 0;
out[4] = (xy - wz) * sy;
out[5] = (1 - (xx + zz)) * sy;
out[6] = (yz + wx) * sy;
out[7] = 0;
out[8] = (xz + wy) * sz;
out[9] = (yz - wx) * sz;
out[10] = (1 - (xx + yy)) * sz;
out[11] = 0;
out[12] = v[0];
out[13] = v[1];
out[14] = v[2];
out[15] = 1;
return out;
}