MCPcopy Create free account
hub / github.com/microsoft/SandDance / fromQuat2

Function fromQuat2

docs/app/js/sanddance-app.js:73570–73585  ·  view source on GitHub ↗
(out, a)

Source from the content-addressed store, hash-verified

73568 return out;
73569}
73570function fromQuat2(out, a) {
73571 var translation = new _commonJs.ARRAY_TYPE(3);
73572 var bx = -a[0], by = -a[1], bz = -a[2], bw = a[3], ax = a[4], ay = a[5], az = a[6], aw = a[7];
73573 var magnitude = bx * bx + by * by + bz * bz + bw * bw; //Only scale if it makes sense
73574 if (magnitude > 0) {
73575 translation[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2 / magnitude;
73576 translation[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2 / magnitude;
73577 translation[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2 / magnitude;
73578 } else {
73579 translation[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2;
73580 translation[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2;
73581 translation[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2;
73582 }
73583 fromRotationTranslation(out, a, translation);
73584 return out;
73585}
73586function getTranslation(out, mat) {
73587 out[0] = mat[12];
73588 out[1] = mat[13];

Callers

nothing calls this directly

Calls 1

fromRotationTranslationFunction · 0.70

Tested by

no test coverage detected