CameraPose

Builds a world WGS84-ECEF -> image-UV 4x4 matrix for a camera at a known geographic position looking at a known geographic target. The output matrix takes a world ECEF position to image clip space; downstream code divides xy/w to land in image UV in 0, 1 across the camera's frustum.

Composition (right-to-left): imageProjection = NDC->UV bias * perspective(vFov, aspect) * lookAt(eye, target, up)

The bias term folds the NDC -1, 1 ->0, 1 mapping into the matrix so the fragment stage only needs the homogeneous divide; no additional shader-side rescale.

Always operates in WGS84 ECEF - independent of any 2D display projection (Mercator, polar, ...) the consuming Globe might use for rendering. The vertices the matrix is applied to come from terrain rendering, which keeps real-Earth ECEF positions regardless of display projection.

Construction is allocation-free after the first call: scratch Vec3/Matrix4s and a private Wgs84Projection are held as fields and reused on each setToLookAt invocation.

The view matrix follows the standard right-handed lookAt(eye, target, up) recipe; up is the ellipsoid surface normal at the camera position. Roll isn't applied (negligible for stabilised drone gimbals; the source-image vertical flip lives in the texture's coord transform).

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

Eye (camera) position in ECEF, set by setToLookAt. Useful for frustum culling.

Link copied to clipboard

Most-recently-built world-to-image matrix. Read after setToLookAt.

Functions

Link copied to clipboard
fun setFromPlatformAndSensorPose(cameraLat: Angle, cameraLon: Angle, cameraAltMeters: Double, pYaw: Angle, pPitch: Angle, pRoll: Angle, sAz: Angle, sEl: Angle, sRoll: Angle, vFov: Angle, aspect: Double, near: Double = 1.0, far: Double): Matrix4

Build the world-to-image matrix from a camera at (cameraLat, cameraLon, cameraAltMeters) whose orientation is the composition of platform body angles (body-to-NED) and sensor relative angles (camera-body-to-platform-body). This is the mathematically correct entry for KLV / MISB ST 0601 streams: tags 5-7 give platform heading/pitch/roll, tags 18-20 give sensor relative azimuth/elevation/roll, and the camera's actual world-frame direction is R_platform * R_sensor * forward_body.

Link copied to clipboard
fun setToLookAt(cameraLat: Angle, cameraLon: Angle, cameraAltMeters: Double, targetLat: Angle, targetLon: Angle, targetAltMeters: Double, vFov: Angle, aspect: Double, near: Double = 1.0, far: Double): Matrix4

Build the world-to-image matrix for a camera at (camera*) looking at (target*), with vertical vFov and image aspect = width/height.