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 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | 1x 1x 1x 1x 1x 1x 1x 1x 578x 117825x 576x 576x 576x 576x 576x 576x 2252x 2252x 2252x 13512x 1153x 12359x 107362x 5451x 6908x 6908x 576x 6332x 6332x 576x 576x 576x 2979x 2979x 1152x 1827x 2982x 2982x 2982x 2982x 2982x 2979x 2403x 576x 3x | // Generated by ReScript, PLEASE EDIT WITH CARE
import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.js";
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
import * as Quaternion$WsteinRegripCore from "./Quaternion.res.mjs";
import * as CubeSymmetry$WsteinRegripCore from "./CubeSymmetry.res.mjs";
let defaults = {
snapDeg: 35,
hysteresisDeg: 6
};
let quarter = Quaternion$WsteinRegripCore.degreesToRadians(90);
let positiveX = Quaternion$WsteinRegripCore.fromEuler({
x: quarter,
y: 0,
z: 0
});
let positiveY = Quaternion$WsteinRegripCore.fromEuler({
x: 0,
y: quarter,
z: 0
});
let positiveZ = Quaternion$WsteinRegripCore.fromEuler({
x: 0,
y: 0,
z: quarter
});
let transitions = [
{
rotation: positiveX,
sensorFrameToken: "x",
notationToken: "x'"
},
{
rotation: Quaternion$WsteinRegripCore.conjugate(positiveX),
sensorFrameToken: "x'",
notationToken: "x"
},
{
rotation: positiveY,
sensorFrameToken: "y",
notationToken: "y'"
},
{
rotation: Quaternion$WsteinRegripCore.conjugate(positiveY),
sensorFrameToken: "y'",
notationToken: "y"
},
{
rotation: positiveZ,
sensorFrameToken: "z",
notationToken: "z'"
},
{
rotation: Quaternion$WsteinRegripCore.conjugate(positiveZ),
sensorFrameToken: "z'",
notationToken: "z"
}
];
let initial_pending = [];
let initial = {
lockedPose: Quaternion$WsteinRegripCore.identity,
emittedPose: Quaternion$WsteinRegripCore.identity,
pending: initial_pending
};
function pose(state) {
return state.emittedPose;
}
function samePose(a, b) {
return Quaternion$WsteinRegripCore.angle(a, b) < 0.00001;
}
function shortestPath(fromPose, toPose) {
Iif (samePose(fromPose, toPose)) {
return [];
}
let queue = [{
pose: fromPose,
path: []
}];
let visited = [fromPose];
let cursor = 0;
let result = {
contents: undefined
};
while (cursor < queue.length && Stdlib_Option.isNone(result.contents)) {
let node = queue[cursor];
cursor = cursor + 1 | 0;
transitions.forEach(transition => {
if (!Stdlib_Option.isNone(result.contents)) {
return;
}
let candidate = Quaternion$WsteinRegripCore.normalize(Quaternion$WsteinRegripCore.multiply(node.pose, transition.rotation));
if (visited.some(existing => samePose(existing, candidate))) {
return;
}
let path = node.path.concat([transition]);
if (samePose(candidate, toPose)) {
result.contents = path;
} else {
visited.push(candidate);
queue.push({
pose: candidate,
path: path
});
}
});
};
let path = result.contents;
if (path !== undefined) {
return path;
} else E{
return Pervasives.failwith("cube orientation graph must be connected");
}
}
function emitNext(state) {
let transition = state.pending[0];
if (transition !== undefined) {
return [
{
lockedPose: state.lockedPose,
emittedPose: Quaternion$WsteinRegripCore.normalize(Quaternion$WsteinRegripCore.multiply(state.emittedPose, transition.rotation)),
pending: state.pending.slice(1)
},
{
sensorFrameToken: transition.sensorFrameToken,
notationToken: transition.notationToken
}
];
} else {
return [
state,
undefined
];
}
}
function step(state, raw, configOpt) {
let config = configOpt !== undefined ? configOpt : defaults;
let raw$1 = Quaternion$WsteinRegripCore.normalize(raw);
let candidate = CubeSymmetry$WsteinRegripCore.nearest(raw$1, state.lockedPose, Quaternion$WsteinRegripCore.degreesToRadians(config.hysteresisDeg));
let isSettled = Quaternion$WsteinRegripCore.angle(raw$1, candidate) <= Quaternion$WsteinRegripCore.degreesToRadians(config.snapDeg);
if (isSettled) {
if (samePose(candidate, state.lockedPose)) {
return emitNext(state);
} else {
return emitNext({
lockedPose: candidate,
emittedPose: state.emittedPose,
pending: shortestPath(state.emittedPose, candidate)
});
}
} else {
return [
state,
undefined
];
}
}
export {
defaults,
initial,
pose,
step,
}
/* quarter Not a pure module */
|