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 | 8410x 8410x | import type { Types } from '@cornerstonejs/core';
import { vec3 } from 'gl-matrix';
type Sphere = {
center: Types.Point3 | vec3;
radius: number;
};
/**
* Checks if a point is inside a sphere. Note: this is similar to the
* `pointInEllipse` function, but since we don't need checks for the
* ellipse's rotation in different views, we can use a simpler equation
* which would be faster (no if statements).
*
* @param sphere - Sphere object with center and radius
* @param pointLPS - the point to check in world coordinates
* @returns boolean
*/
export default function pointInSphere(
sphere: Sphere,
pointLPS: Types.Point3
): boolean {
const { center, radius } = sphere;
return (
(pointLPS[0] - center[0]) ** 2 +
(pointLPS[1] - center[1]) ** 2 +
(pointLPS[2] - center[2]) ** 2 <=
radius ** 2
);
}
|