Skip to main content

Function: getEffectiveSpacingAlongDirection()

getEffectiveSpacingAlongDirection(volume, direction): number

The distance you must travel along direction to cross one voxel-equivalent of the volume's grid.

For a unit direction d and voxel axes i, j, k with spacings sᵢ:

  s_eff = 1 / sqrt( Σᵢ (d · aᵢ / sᵢ)² )

This is the reciprocal of the rate at which grid boundaries are crossed, so it is the right quantity for choosing a sampling step along an arbitrary direction: sample at s_eff and you visit one voxel-equivalent per step no matter how the direction is oriented relative to the grid. It reduces to sᵢ exactly when d is parallel to axis i, since the other two dot products vanish.

This is the third of three "spacing along a direction" measures in the codebase, and they answer different questions:

  • getSpacingInNormalDirection - the L2 length of the projected spacing vector, sqrt( Σᵢ (d · aᵢ · sᵢ)² ). "How far does the camera dolly before it sees a new set of voxels."
  • getVoxelThicknessAlongNormal - the L1 length, Σᵢ |d · aᵢ| · sᵢ. How far a single voxel reaches along the direction, which is what a voxel/slab overlap test needs.
  • this one - the harmonic form. How far to step to cross one voxel.

All three agree when d is parallel to a voxel axis, and diverge for oblique directions.

Parameters

volume: ImageVolume | object

The volume, or anything carrying its direction and spacing.

direction: Point3

The direction to measure along. Assumed to be a unit vector.

Returns

number

The effective spacing along direction, in world units (mm).

Defined in

packages/core/src/utilities/getEffectiveSpacingAlongDirection.ts:40