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 | import { vec3 } from 'gl-matrix';
import { utilities } from '@cornerstonejs/core';
import type { Types } from '@cornerstonejs/core';
import { ORIENTATION_TOLERANCE } from './constants';
/**
* Maps a camera normal vector to an orientation string.
* Returns 'AXIAL', 'CORONAL', 'SAGITTAL', or null if not matched.
*
* @param normal - The view plane normal vector
* @returns The orientation string or null if not matched
*/
export function getOrientationFromNormal(
normal: Types.Point3
): 'AXIAL' | 'CORONAL' | 'SAGITTAL' | null {
if (!normal) {
return null;
}
const canonical = {
AXIAL: [0, 0, 1],
CORONAL: [0, 1, 0],
SAGITTAL: [1, 0, 0],
};
for (const [key, value] of Object.entries(canonical)) {
if (
utilities.isEqualAbs(
1,
vec3.dot(value as Types.Point3, normal),
ORIENTATION_TOLERANCE
)
) {
return key as 'AXIAL' | 'CORONAL' | 'SAGITTAL';
}
}
return null;
}
|