Maths · function
rayPlane
Where a ray meets an infinite plane, or -1.
Explained in Coordinates and units.
function rayPlane(origin: ArrayLike<number>, direction: ArrayLike<number>, point: ArrayLike<number>, normal: ArrayLike<number>): numberimport { rayPlane } from '@driftengine/core';Parameters
| Parameter | Type | Description |
|---|---|---|
origin | ArrayLike<number> | |
direction | ArrayLike<number> | |
point | ArrayLike<number> | |
normal | ArrayLike<number> |
In depth
The plane is a point and a normal rather than four coefficients, because every caller
here has a point — a gizmo's origin, a target's position — and would otherwise compute
d to have it undone one line later.
A ray within 1e-6 of parallel is a miss and not a hit at infinity. The alternative
returns a number that is finite, enormous and wrong, and what a caller does with it is
teleport whatever it was dragging. Callers that grab against a plane depend on this
refusal; see gizmo.ts.
The normal does not have to be unit length, but direction and normal must be in the
same space, and a plane behind the ray reports -1 the way every other miss does.