// copied from ghostwolf and
// https://www.blend4web.com/api_doc/libs_gl-matrix2.js.html
public static void fromRotationTranslationScaleOrigin(final Quaternion q, final Vector3 v, final Vector3 s,
final Matrix4 out, final Vector3 pivot) {
final float x = q.x;
final float y = q.y;
final float z = q.z;
final float w = q.w;
final float x2 = x + x;
final float y2 = y + y;
final float z2 = z + z;
final float xx = x * x2;
final float xy = x * y2;
final float xz = x * z2;
final float yy = y * y2;
final float yz = y * z2;
final float zz = z * z2;
final float wx = w * x2;
final float wy = w * y2;
final float wz = w * z2;
final float sx = s.x;
final float sy = s.y;
final float sz = s.z;
out.val[Matrix4.M00] = (1 - (yy + zz)) * sx;
out.val[Matrix4.M10] = (xy + wz) * sx;
out.val[Matrix4.M20] = (xz - wy) * sx;
out.val[Matrix4.M30] = 0;
out.val[Matrix4.M01] = (xy - wz) * sy;
out.val[Matrix4.M11] = (1 - (xx + zz)) * sy;
out.val[Matrix4.M21] = (yz + wx) * sy;
out.val[Matrix4.M31] = 0;
out.val[Matrix4.M02] = (xz + wy) * sz;
out.val[Matrix4.M12] = (yz - wx) * sz;
out.val[Matrix4.M22] = (1 - (xx + yy)) * sz;
out.val[Matrix4.M32] = 0;
out.val[Matrix4.M03] = (v.x + pivot.x) - ((out.val[Matrix4.M00] * pivot.x) + (out.val[Matrix4.M01] * pivot.y)
+ (out.val[Matrix4.M02] * pivot.z));
out.val[Matrix4.M13] = (v.y + pivot.y) - ((out.val[Matrix4.M10] * pivot.x) + (out.val[Matrix4.M11] * pivot.y)
+ (out.val[Matrix4.M12] * pivot.z));
out.val[Matrix4.M23] = (v.z + pivot.z) - ((out.val[Matrix4.M20] * pivot.x) + (out.val[Matrix4.M21] * pivot.y)
+ (out.val[Matrix4.M22] * pivot.z));
out.val[Matrix4.M33] = 1;
}