fromRotationTranslation function
Creates a matrix from a quaternion rotation and vector translation 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);
@param {mat4} out mat4 receiving operation result @param {quat4} q Rotation quaternion @param {ReadonlyVec3} v Translation vector @returns {mat4} out
Implementation
List<double> fromRotationTranslation(List<double> out, List<double> q, List<double> v) {
// 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;
out[0] = 1 - (yy + zz);
out[1] = xy + wz;
out[2] = xz - wy;
out[3] = 0;
out[4] = xy - wz;
out[5] = 1 - (xx + zz);
out[6] = yz + wx;
out[7] = 0;
out[8] = xz + wy;
out[9] = yz - wx;
out[10] = 1 - (xx + yy);
out[11] = 0;
out[12] = v[0];
out[13] = v[1];
out[14] = v[2];
out[15] = 1;
return out;
}