quaternion-multiplication

Benchmark created by Ariya Hidayat on


Preparation HTML

<script>
  var dest = [0.4642383454426296, 0, -0.18569533817705183, 0.8660254037844387];
  var q = [0.12101512690846804, 0.3630453807254041, 0, 0.9238795325112867];
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
standard
var aX = dest[0],
    aY = dest[1],
    aZ = dest[2],
    aW = dest[3],
    bX = q[0],
    bY = q[1],
    bZ = q[2],
    bW = q[3];

dest[0] = aW * bX + aX * bW + aY * bZ - aZ * bY;
dest[1] = aW * bY + aY * bW + aZ * bX - aX * bZ;
dest[2] = aW * bZ + aZ * bW + aX * bY - aY * bX;
dest[3] = aW * bW - aX * bX - aY * bY - aZ * bZ;
ready
factorized
var aX = dest[0],
    aY = dest[1],
    aZ = dest[2],
    aW = dest[3],
    bX = q[0],
    bY = q[1],
    bZ = q[2],
    bW = q[3],
    ww = (aZ + aX) * (bX + bY),
    yy = (aW - aY) * (bW + bZ),
    zz = (aW + aY) * (bW - bZ),
    xx = ww + yy + zz,
    qq = 0.5 * (xx + (aZ - aX) * (bX - bY));

dest[0] = qq - xx + (aX + aW) * (bX + bW);
dest[1] = qq - yy + (aW - aX) * (bY + bZ);
dest[2] = qq - zz + (aZ + aY) * (bW - bX);
dest[3] = qq - ww + (aZ - aY) * (bY - bZ);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.