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 | 1x 4x 15x 4x 2x 6x 6x 6x 6x 2x 2x 1x | import type { t as SensorToBody } from '@wstein/regrip-core/domain/SensorToBody';
const axes = new Set(['x', 'y', 'z']);
/** Parse profile syntax such as `x,z,-y,w`; the final `w` is required. */
export function parseSensorToBodyAxisMap(value: string | undefined): SensorToBody | undefined {
Iif (!value) return undefined;
const parts = value.split(',').map((part) => part.trim());
if (parts.length !== 4 || parts[3] !== 'w') return undefined;
const components = parts.slice(0, 3).map((part) => {
const negative = part.startsWith('-');
const axis = negative ? part.slice(1) : part;
return axes.has(axis)
? { axis: axis.toUpperCase() as 'X' | 'Y' | 'Z', sign: negative ? -1 : 1 }
: undefined;
});
Iif (components.some((component) => !component)) return undefined;
const [x, y, z] = components as SensorToBody['x'][];
if (new Set([x.axis, y.axis, z.axis]).size !== 3) return undefined;
return { x, y, z };
}
|