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 | 8410x 33640x 33640x 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; const [x, y, z] = pointLPS; const [x0, y0, z0] = center; return (x - x0) ** 2 + (y - y0) ** 2 + (z - z0) ** 2 <= radius ** 2; } |