quaternion-multiplication

JavaScript performance comparison

Test case created by Ariya Hidayat

Preparation code

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

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/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;
pending…
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);
pending…

Compare results of other browsers

Revisions

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

0 Comments