Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | 9x 13894x 25x 42x 567445x 567445x 1x 567444x 275403x 275206x 275206x 44x 44x 44x 44x 23x 21x 21x 21x 21x 21x 62x 62x 62x 62x 62x 62x 62x 6146x | // Generated by ReScript, PLEASE EDIT WITH CARE
let identity = {
x: 0,
y: 0,
z: 0,
w: 1
};
function multiply(a, b) {
return {
x: a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y,
y: a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z,
z: a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x,
w: a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z
};
}
function premultiply(self, other) {
return multiply(other, self);
}
function conjugate(q) {
return {
x: - q.x,
y: - q.y,
z: - q.z,
w: q.w
};
}
function normalize(q) {
let len = Math.sqrt(q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w);
if (len === 0) {
return identity;
} else {
return {
x: q.x / len,
y: q.y / len,
z: q.z / len,
w: q.w / len
};
}
}
function dot(a, b) {
return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
}
function angle(a, b) {
let d = Math.abs(dot(normalize(a), normalize(b)));
return 2 * Math.acos(d > 1 ? 1 : d);
}
function slerp(a, b, t) {
let b$1 = dot(a, b) < 0 ? ({
x: - b.x,
y: - b.y,
z: - b.z,
w: - b.w
}) : b;
let rawCosine = dot(normalize(a), normalize(b$1));
let cosine = rawCosine > 1 ? 1 : (
rawCosine < -1 ? -1 : rawCosine
);
if (cosine > 0.9995) {
return normalize({
x: a.x + t * (b$1.x - a.x),
y: a.y + t * (b$1.y - a.y),
z: a.z + t * (b$1.z - a.z),
w: a.w + t * (b$1.w - a.w)
});
}
let theta = Math.acos(cosine);
let sinTheta = Math.sin(theta);
let wa = Math.sin((1 - t) * theta) / sinTheta;
let wb = Math.sin(t * theta) / sinTheta;
return {
x: wa * a.x + wb * b$1.x,
y: wa * a.y + wb * b$1.y,
z: wa * a.z + wb * b$1.z,
w: wa * a.w + wb * b$1.w
};
}
function fromEuler(e) {
let c1 = Math.cos(e.x / 2);
let c2 = Math.cos(e.y / 2);
let c3 = Math.cos(e.z / 2);
let s1 = Math.sin(e.x / 2);
let s2 = Math.sin(e.y / 2);
let s3 = Math.sin(e.z / 2);
return {
x: s1 * c2 * c3 + c1 * s2 * s3,
y: c1 * s2 * c3 - s1 * c2 * s3,
z: c1 * c2 * s3 + s1 * s2 * c3,
w: c1 * c2 * c3 - s1 * s2 * s3
};
}
function degreesToRadians(deg) {
return deg * Math.PI / 180;
}
export {
identity,
multiply,
premultiply,
conjugate,
normalize,
dot,
angle,
slerp,
fromEuler,
degreesToRadians,
}
/* No side effect */
|