ships.Function.projectGunsight - Elite-Dangerous-Almanac/Almanac-Core GitHub Wiki

@elite-dangerous-almanac/core / ships / projectGunsight

Function: projectGunsight()

projectGunsight(gunsight, targetRangeMetres): readonly GunsightPoint[]

Defined in: src/ships/gunsights.ts:124

Project a gunsight onto a target plane at a chosen range.

Parameters

gunsight

ShipGunsight

Camera-relative hardpoint offsets in metres, normally returned by getShipGunsight.

targetRangeMetres

number

Finite target-plane distance in metres; must be greater than zero.

Returns

readonly GunsightPoint[]

One dimensionless angular-tangent point per input offset, preserving its order. To place a point on a perspective display, divide horizontalTangent and verticalTangent by the tangent of the corresponding half field of view; invert the vertical result when screen coordinates increase downwards.

Remarks

This is fixed, ship-forward geometry. It does not model gimbal or turret tracking, projectile travel, target motion, or head-look.

Throws

If targetRangeMetres is not finite and greater than zero.

Example

import {
  getShipGunsight,
  projectGunsight,
} from '@elite-dangerous-almanac/core/ships/gunsights';

const gunsight = getShipGunsight('SideWinder')!;
projectGunsight(gunsight, 1000)[0];
// -> { horizontalTangent: -0.0021956754, verticalTangent: -0.001166162 }
⚠️ **GitHub.com Fallback** ⚠️