StackGenVis: Alignment of Data, Algorithms, and Models for Stacking Ensemble Learning Using Performance Metrics
https://doi.org/10.1109/TVCG.2020.3030352
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
848 B
28 lines
848 B
4 years ago
|
module.exports = transformQuat;
|
||
|
|
||
|
/**
|
||
|
* Transforms the vec3 with a quat
|
||
|
*
|
||
|
* @param {vec3} out the receiving vector
|
||
|
* @param {vec3} a the vector to transform
|
||
|
* @param {quat} q quaternion to transform with
|
||
|
* @returns {vec3} out
|
||
|
*/
|
||
|
function transformQuat(out, a, q) {
|
||
|
// benchmarks: http://jsperf.com/quaternion-transform-vec3-implementations
|
||
|
|
||
|
var x = a[0], y = a[1], z = a[2],
|
||
|
qx = q[0], qy = q[1], qz = q[2], qw = q[3],
|
||
|
|
||
|
// calculate quat * vec
|
||
|
ix = qw * x + qy * z - qz * y,
|
||
|
iy = qw * y + qz * x - qx * z,
|
||
|
iz = qw * z + qx * y - qy * x,
|
||
|
iw = -qx * x - qy * y - qz * z
|
||
|
|
||
|
// calculate result * inverse quat
|
||
|
out[0] = ix * qw + iw * -qx + iy * -qz - iz * -qy
|
||
|
out[1] = iy * qw + iw * -qy + iz * -qx - ix * -qz
|
||
|
out[2] = iz * qw + iw * -qz + ix * -qy - iy * -qx
|
||
|
return out
|
||
|
}
|