Ray-Tracing Short-Throw Projector Shadow Cones and Ceiling Obstacles in Browser TypeScript
When building a browser-based 3D CAD tool for indoor projection spaces (like short-throw golf simulator bays or home theaters), basic throw-ratio calculators (throwDistance = imageWidth * throwRatio) miss the failure mode that actually breaks real installations: volumetric occlusion.
A projector can hit the exact screen dimensions on paper and still cast a permanent silhouette across the screen if:
- The lower ray of the projection frustum clips a person's head or follow-through club arc, or
- The upper ray clips a ceiling-mounted obstacle (such as a ceiling structural beam, garage door opener rail, or an overhead ceiling launch monitor bar hanging 4 to 6 inches below the joists).
Here is the deterministic TypeScript geometry model we use to evaluate projector throw cones and shadow collisions in real time at 60 FPS without heavy GPU ray-marching.
1. Defining the Ceiling-Mounted Optical Frustum
In a right-handed 3D coordinate system where:
-
X= lateral room width (0at bay center) -
Y= vertical height above finished floor (0at floor slab) -
Z= distance forward from the impact screen (0at impact screen plane, positive moving back toward the viewer/golfer)
A ceiling-mounted inverted projector sits at lens coordinate (xL, yL, zL). Its throw ratio range [minTR, maxTR] and vertical lens offset percentage offsetPct determine where the top and bottom edges of the projected image land on the screen (Z = 0):
export interface ProjectorSpec { minThrowRatio: number; maxThrowRatio: number; verticalOffsetPct: number; // e.g., 105 means top of image sits 5% below lens axis when inverted nativeAspect: number; // 16/9, 16/10, or 4/3 } export interface ScreenBounds { widthIn: number; heightIn: number; bottomYIn: number; // height of screen bottom edge above slab } export interface Ray2D { originZ: number; originY: number; targetZ: number; targetY: number; } For an inverted ceiling mount, the top edge of the projected screen sits at screenTopY = screen.bottomYIn + screen.heightIn, and the required lens height above the floor is:
export function computeCeilingLensY( screen: ScreenBounds, spec: ProjectorSpec ): number { const screenTopY = screen.bottomYIn + screen.heightIn; // Standard DLP offset: 100% = lens flush with top edge; 110% = lens 10% of image height above top edge const offsetAboveTop = ((spec.verticalOffsetPct - 100) / 100) * screen.heightIn; return screenTopY + offsetAboveTop; } Notice a subtle bug that trips up many calculators: non-native aspect cropping. If a 16:9 projector (1920x1080) projects onto a 4:3 screen (120" x 90") by pillar-boxing horizontally (using full vertical height), the effective width that governs throw distance is the full native 16:9 width (90 * 16/9 = 160"), NOT the 120" physical screen width! Failing to compute throw distance from the native active matrix width puts the ceiling mount 2 to 3 feet too close to the screen.
export function computeEffectiveNativeWidth( screenWidthIn: number, screenHeightIn: number, nativeAspect: number ): number { const screenAspect = screenWidthIn / screenHeightIn; if (nativeAspect > screenAspect) { // Pillar-boxed horizontally: height fills full chip, active optical width is wider return screenHeightIn * nativeAspect; } return screenWidthIn; } 2. Linear Ray Evaluation Against Vertical Obstacles (Golfer & Overhead Sensors)
Because the upper and lower frustum boundary planes are linear functions of Z in the side elevation (Y-Z plane), checking whether ANY point (zObj, yObj) penetrates the projection beam reduces to interpolating the beam ceiling and beam floor at zObj:
export function beamBoundsAtZ( lensZ: number, lensY: number, screen: ScreenBounds, zQuery: number ): { beamBottomY: number; beamTopY: number } | null { if (zQuery <= 0 || zQuery >= lensZ) return null; const t = zQuery / lensZ; // 0 at screen, 1 at projector lens const screenTopY = screen.bottomYIn + screen.heightIn; const beamTopY = screenTopY + t * (lensY - screenTopY); const beamBottomY = screen.bottomYIn + t * (lensY - screen.bottomYIn); return { beamBottomY, beamTopY }; } Now check the two highest-cost physical collisions:
A. Golfer Head & Backswing Shadow Check
At the golfer's stance plane zGolfer (typically ballToScreenIn plus stance shift), the golfer's head crown sits at yHead = matThicknessIn + golferHeightIn. The vertical margin is simply:
const bounds = beamBoundsAtZ(lensZ, lensY, screen, zGolfer); const headClearanceIn = bounds ? bounds.beamBottomY - (matThicknessIn + golferHeightIn) : Infinity; If headClearanceIn < 0, the bottom ray intersects the golfer's head and projects a dark shadow onto the lower screen by projecting the vector (lensZ, lensY) -> (zGolfer, yHead) forward to Z = 0:
export function projectShadowHeightOnScreen( lensZ: number, lensY: number, obstacleZ: number, obstacleTopY: number ): number { const slope = (obstacleTopY - lensY) / (obstacleZ - lensZ); return lensY + slope * (0 - lensZ); } B. Overhead Ceiling Sensor Occlusion Check
Overhead ceiling launch monitor bars (such as units mounted ~42 inches ahead of the tee at 9'–10' ceiling height) hang 4" to 6" below the finished ceiling. If the ceiling projector sits behind the overhead bar (lensZ > sensorZ), the sensor's bottom face sensorBottomY = ceilingHeightIn - sensorDropIn must sit strictly above beamTopY at sensorZ:
const sensorBounds = beamBoundsAtZ(lensZ, lensY, screen, sensorZ); const sensorClearsBeam = !sensorBounds || sensorBottomY >= sensorBounds.beamTopY + 0.5; When sensorClearsBeam is false, the fix is either increasing the projector drop-tube length (if ceiling height allows without violating swing clearance) or switching to a shorter-throw lens (0.49–0.55 ratio) so the projector mounts cleanly in front of or vertically offset from the overhead sensor housing.
3. Why Deterministic Elevation Math Beats Manual Guesswork
Running this exact 2D/3D analytical solver client-side means every slider drag (room height, hitting mat thickness, screen aspect ratio, projector model, or overhead sensor) recomputes shadow margins in under 0.1 milliseconds, flags exact collision coordinates in inches, and renders the live ray cone directly in Three.js.
You can test the live 3D optical ray-tracer across 36 short-throw projectors and 18 launch monitors at https://www.simbaycad.com/guides/golf-simulator-projector-throw-distance.