Skip to main content

Coordinates and Transforms API

Source headers: raptor/crs.hpp, raptor/geo.hpp, raptor/quaternion.hpp, raptor/transforms.hpp

raptor​

Types​

NameDescription
CrsCoordinate Reference System wrapper holding either ECEF or Geodetic CRS.
Pose
Position
QuaternionUnit quaternion representing a 3D rotation.
Ray

Functions​

NameDescription
cameraRelativeToNedOrientation of the camera relative to local.
nedRelativeToCameraOrientation of local.

Function Details​

cameraRelativeToNed​
Function
Quaternion cameraRelativeToNed(const Pose& pose)

Orientation of the camera relative to local North-East-Down (NED) at the pose's location.

Equals the attitude of the pose expressed as a pose::Geodetic. Its rotation matrix converts camera-frame vector components into NED components. Throws: std::invalid_argument - If the pose is invalid or cannot be converted.

nedRelativeToCamera​
Function
Quaternion nedRelativeToCamera(const Pose& pose)

Orientation of local North-East-Down (NED) relative to the camera at the pose's location.

The conjugate of cameraRelativeToNed(pose). Its rotation matrix converts NED vector components into camera-frame components. Throws: std::invalid_argument - If the pose is invalid or cannot be converted.

raptor::Crs​

class Crs

Coordinate Reference System wrapper holding either ECEF or Geodetic CRS.

Functions​

NameDescription
CrsDefault constructor - creates a default ECEF CRS.
CrsConstruct from an ECEF CRS.
CrsConstruct from a Geodetic CRS.

Function Details​

Crs​

Function
Crs()

Default constructor - creates a default ECEF CRS

Function
Crs(const crs::Ecef& crs) noexcept

Construct from an ECEF CRS

Function
Crs(const crs::Geodetic& crs) noexcept

Construct from a Geodetic CRS

raptor::Pose​

class Pose

Functions​

NameDescription
PoseDefault constructor - creates identity ECEF pose.
PoseConstruct from an ECEF pose.
PoseConstruct from a Geodetic pose.

Function Details​

Pose​

Function
Pose()

Default constructor - creates identity ECEF pose

Creates a pose at origin (0,0,0) with identity attitude.

Function
Pose(const pose::Ecef& pose)

Construct from an ECEF pose. Validates that coordinates are finite and the attitude quaternion is normalized. Throws: std::invalid_argument - If coordinates are not finite or attitude is not normalized.

Function
Pose(const pose::Geodetic& pose)

Construct from a Geodetic pose. Validates coordinate ranges (per CRS units) and that the attitude quaternion is normalized. Throws: std::invalid_argument - If coordinates are out of range / not finite, or the attitude quaternion is not normalized.

raptor::Position​

class Position

Functions​

NameDescription
PositionDefault constructor - creates identity ECEF position.
PositionConstruct from an ECEF position.
PositionConstruct from a Geodetic position.

Function Details​

Position​

Function
Position()

Default constructor - creates identity ECEF position

Creates a position at origin (0,0,0).

Function
Position(const position::Ecef& pos)

Construct from an ECEF position. Validates that coordinates are finite. Throws: std::invalid_argument - If coordinates are not finite.

Function
Position(const position::Geodetic& pos)

Construct from a Geodetic position. Validates coordinate ranges (per CRS units). Throws: std::invalid_argument - If coordinates are out of range or not finite.

raptor::Quaternion​

struct Quaternion

Unit quaternion representing a 3D rotation

Quaternion using [x, y, z, w] convention where w is the scalar component. The quaternion must be normalized (unit quaternion with x² + y² + z² + w² = 1).

As a pose attitude, the quaternion is the orientation of the camera frame relative to the attitude frame of the pose, which is determined by the pose's coordinate system:

  • pose::Ecef -> ECEF axes
  • pose::Geodetic -> local North-East-Down (NED) axes

Its rotation matrix \fR\f R \f converts camera-frame vector components into attitude-frame components: \fvatt=R⋅vcam\f v_{att} = R \cdot v_{cam} \f. Its columns are the camera axes expressed in the attitude frame.

The camera frame follows the DIN 9300 convention:

  • X-axis: Forward (optical axis, into the scene)
  • Y-axis: Right
  • Z-axis: Down

Functions​

NameDescription
fromMatrixCreate quaternion from a 3x3 rotation matrix (row-major).
toMatrixConvert quaternion to a 3x3 rotation matrix (row-major).
fromEulerCreate quaternion from intrinsic Z-Y-X Euler angles (yaw, pitch, roll).
toEulerConvert quaternion to intrinsic Z-Y-X Euler angles (yaw, pitch, roll).
normSquaredGet the squared norm of the quaternion.
normGet the norm of the quaternion.
normalizeNormalize the quaternion to unit length.
isNormalizedCheck if quaternion is approximately unit length.

Function Details​

fromMatrix​

Function
[[nodiscard]] static Quaternion fromMatrix(const std::array<double, 9>& matrix)

Create quaternion from a 3x3 rotation matrix (row-major)

Uses the algorithm from "Accurate computation of quaternions from rotation matrices" by Sarabandi & Thomas for numerical stability.

Parameters:

  • matrix - Row-major 3x3 rotation matrix [R00, R01, R02, R10, R11, R12, R20, R21, R22]

Returns: Quaternion representing the same rotation

toMatrix​

Function
[[nodiscard]] std::array<double, 9> toMatrix() const

Convert quaternion to a 3x3 rotation matrix (row-major)

Returns: Row-major 3x3 rotation matrix [R00, R01, R02, R10, R11, R12, R20, R21, R22]

fromEuler​

Function
[[nodiscard]] static Quaternion fromEuler(double yaw, double pitch, double roll)

Create quaternion from intrinsic Z-Y-X Euler angles (yaw, pitch, roll)

Convention: the combined rotation is R = Rz(yaw) * Ry(pitch) * Rx(roll), applied to a column vector. Inputs are in radians.

Parameters:

  • yaw - Rotation about the Z axis (radians)
  • pitch - Rotation about the Y axis (radians)
  • roll - Rotation about the X axis (radians)

Returns: Normalized quaternion representing the same rotation

toEuler​

Function
[[nodiscard]] std::array<double, 3> toEuler() const

Convert quaternion to intrinsic Z-Y-X Euler angles (yaw, pitch, roll)

Inverse of fromEuler. Returned angles are in radians with ranges:

  • yaw ∈ (-π, π]
  • pitch ∈ [-π/2, π/2]
  • roll ∈ (-π, π]

Near gimbal lock (|pitch| ≈ π/2) yaw and roll become coupled and the split between them is not unique; callers should handle that case explicitly.

Returns: Array {yaw, pitch, roll} in radians

normSquared​

Function
[[nodiscard]] double normSquared() const noexcept

Get the squared norm of the quaternion

Returns: x² + y² + z² + w²

norm​

Function
[[nodiscard]] double norm() const noexcept

Get the norm of the quaternion

Returns: sqrt(x² + y² + z² + w²)

normalize​

Function
[[nodiscard]] Quaternion normalize() const noexcept

Normalize the quaternion to unit length

Returns: Normalized quaternion. If the quaternion is numerically zero (norm < 1e-15), the identity quaternion is returned instead.

isNormalized​

Function
[[nodiscard]] bool isNormalized() const noexcept

Check if quaternion is approximately unit length

Returns: True if quaternion is normalized within tolerance (1e-6)

raptor::Ray​

class Ray

Functions​

NameDescription
RayDefault constructor - creates a zero ECEF ray.
RayConstruct from an ECEF ray.
RayConstruct from a Geodetic ray.

Function Details​

Ray​

Function
Ray()

Default constructor - creates a zero ECEF ray

Default-constructed Ray holds a zero-magnitude direction and is not valid for use; pass through one of the validating constructors before querying.

Function
Ray(const ray::Ecef& ray)

Construct from an ECEF ray. Validates that the origin is finite and the direction has finite components and non-zero magnitude. Throws: std::invalid_argument - If the origin or direction is invalid.

Function
Ray(const ray::Geodetic& ray)

Construct from a Geodetic ray. Validates origin coordinate ranges (per CRS units) and that the NED direction has finite components and non-zero magnitude. Throws: std::invalid_argument - If the origin or direction is invalid.

raptor::coordinates​

Types​

NameDescription
EcefECEF coordinates (Earth-Centered, Earth-Fixed) in meters.
GeodeticGeodetic coordinates (latitude, longitude, altitude).

raptor::coordinates::Ecef​

struct Ecef

ECEF coordinates (Earth-Centered, Earth-Fixed) in meters

The CRS context is provided by the containing Position or Pose type.

raptor::coordinates::Geodetic​

struct Geodetic

Geodetic coordinates (latitude, longitude, altitude)

Units, height system, and axes convention are defined by the containing Position or Pose type's CRS.

raptor::crs​

Types​

NameDescription
CoordinateSystemCoordinate system type - runtime enum.
EcefECEF (Earth-Centered Earth-Fixed).
GeodeticGeodetic Coordinate Reference System Geodetic coordinate reference system.
HeightSystemHeight system (reference surface for altitude) - runtime enum.
HorizontalUnitAngular unit for horizontal coordinates (lat/lon) - runtime enum.
ReferenceFrameReference frame (datum) - runtime enum.
VerticalUnitLinear unit for vertical coordinate (altitude) - runtime enum.

raptor::crs::CoordinateSystem​

enum class CoordinateSystem : std::uint8_t

Coordinate system type - runtime enum

Ecef : Earth-Centered Earth-Fixed Cartesian coordinate system

Geodetic : Geodetic coordinate system (latitude, longitude, height)

raptor::crs::Ecef​

struct Ecef

ECEF (Earth-Centered Earth-Fixed) Coordinate Reference System

Earth-Centered Earth-Fixed Cartesian coordinate reference system.

  • Position: [X, Y, Z] in meters from Earth's center according to the specified reference frame.
  • Attitude (in Pose): Orientation relative to ECEF axes.

Variables​

NameDescription
referenceFrameReference frame (default: ITRF2008).

Variable Details​

referenceFrame​
ReferenceFrame referenceFrame

Reference frame (default: ITRF2008)

raptor::crs::Geodetic​

struct Geodetic

Geodetic Coordinate Reference System

Geodetic coordinate reference system.

  • Coordinates: [Latitude, Longitude, Height above reference surface] where height is positive upward (NEU (North-East-Up) convention).
  • Attitude (in Pose): Orientation relative to the local NED (North-East-Down) frame.

Variables​

NameDescription
referenceFrameReference frame (default: ITRF2008).
horizontalUnitAngular unit for lat/lon (default: Degrees).
verticalUnitLinear unit for altitude (default: Meter).
heightSystemReference surface for height (default: Ellipsoid/HAE).

Variable Details​

heightSystem​
HeightSystem heightSystem

Reference surface for height (default: Ellipsoid/HAE)

horizontalUnit​
HorizontalUnit horizontalUnit

Angular unit for lat/lon (default: Degrees)

referenceFrame​
ReferenceFrame referenceFrame

Reference frame (default: ITRF2008)

verticalUnit​
VerticalUnit verticalUnit

Linear unit for altitude (default: Meter)

raptor::crs::HeightSystem​

enum class HeightSystem : std::uint8_t

Height system (reference surface for altitude) - runtime enum

Ellipsoid : WGS84 Ellipsoid height (HAE - Height Above Ellipsoid)

Egm2008 : EGM2008 Geoid height (HAMSL - Height Above Mean Sea Level approximation)

Egm96 : EGM96 Geoid height (HAMSL - lower resolution than EGM2008)

raptor::crs::HorizontalUnit​

enum class HorizontalUnit : std::uint8_t

Angular unit for horizontal coordinates (lat/lon) - runtime enum

Radians : Radians

Degrees : Degrees

raptor::crs::ReferenceFrame​

enum class ReferenceFrame : std::uint8_t

Reference frame (datum) - runtime enum

Wgs84g1674 : WGS84 (G1674) reference frame

Itrf2008 : ITRF2008 reference frame

raptor::crs::VerticalUnit​

enum class VerticalUnit : std::uint8_t

Linear unit for vertical coordinate (altitude) - runtime enum

Meter : Meters

Foot : International foot (exactly 0.3048 meters)

raptor::direction​

Types​

NameDescription
EcefDirection vector in ECEF axes.
NedDirection vector in a local NED (North-East-Down) frame.

raptor::direction::Ecef​

struct Ecef

Direction vector in ECEF axes

Components along the Earth-Centered, Earth-Fixed axes.

raptor::direction::Ned​

struct Ned

Direction vector in a local NED (North-East-Down) frame

Components in the local NED frame at the associated origin.

raptor::pose​

Types​

NameDescription
EcefECEF Pose The CRS is stored as a member variable and describes how the data should be interpreted.
GeodeticGeodetic Pose The CRS is stored as a member variable and describes how the data should be interpreted.

raptor::pose::Ecef​

struct Ecef

ECEF Pose

The CRS is stored as a member variable and describes how the data should be interpreted.

pose::Ecef pose{
.coords = {4000000, 300000, 5000000},
.attitude = {0, 0, 0, 1},
.crs = {.referenceFrame = ReferenceFrame::Wgs84g1674}
};

See: crs::Ecef for CRS details

Variables​

NameDescription
coords[X, Y, Z] coordinates in meters.
attitudeOrientation [x, y, z, w] relative to ECEF axes.
crsCoordinate reference system (CRS).

Variable Details​

attitude​
Quaternion attitude

Orientation [x, y, z, w] relative to ECEF axes

coords​
coordinates::Ecef coords

[X, Y, Z] coordinates in meters

crs​
crs::Ecef crs

Coordinate reference system (CRS)

raptor::pose::Geodetic​

struct Geodetic

Geodetic Pose

The CRS is stored as a member variable and describes how the data should be interpreted.

pose::Geodetic pose{
.coords = {51.5, -0.1, 100.0},
.attitude = {0, 0, 0, 1},
.crs = {.horizontalUnit = HorizontalUnit::Degrees}
};

Variables​

NameDescription
coords[lat, lon, alt] with the altitude being positive upwards and the height above the reference surface (units per CRS).
attitudeOrientation [x, y, z, w] relative to local NED frame.
crsCoordinate reference system (CRS).

Variable Details​

attitude​
Quaternion attitude

Orientation [x, y, z, w] relative to local NED frame

coords​
coordinates::Geodetic coords

[lat, lon, alt] with the altitude being positive upwards and the height above the reference surface (units per CRS)

crs​
crs::Geodetic crs

Coordinate reference system (CRS)

raptor::position​

Types​

NameDescription
EcefECEF Position The CRS is stored as a member variable and describes how the data should be interpreted.
GeodeticGeodetic Position The CRS is stored as a member variable and describes how the data should be interpreted.

raptor::position::Ecef​

struct Ecef

ECEF Position

The CRS is stored as a member variable and describes how the data should be interpreted.

position::Ecef pos{
.coords = {4000000, 300000, 5000000},
.crs = {.referenceFrame = ReferenceFrame::Wgs84g1674}
};

Variables​

NameDescription
coords[X, Y, Z] coordinates in meters.
crsCoordinate reference system (CRS).

Variable Details​

coords​
coordinates::Ecef coords

[X, Y, Z] coordinates in meters

crs​
crs::Ecef crs

Coordinate reference system (CRS)

raptor::position::Geodetic​

struct Geodetic

Geodetic Position

The CRS is stored as a member variable and describes how the data should be interpreted.

position::Geodetic pos{
.coords = {51.5, -0.1, 100.0},
.crs = {.horizontalUnit = HorizontalUnit::Degrees}
};

Variables​

NameDescription
coords[lat, lon, alt] with NEU axis convention (units per CRS).
crsCoordinate reference system (CRS).

Variable Details​

coords​
coordinates::Geodetic coords

[lat, lon, alt] with NEU axis convention (units per CRS)

crs​
crs::Geodetic crs

Coordinate reference system (CRS)

raptor::ray​

Types​

NameDescription
EcefECEF Ray (origin + direction).
GeodeticGeodetic Ray (origin + direction in local NED).

raptor::ray::Ecef​

struct Ecef

ECEF Ray (origin + direction)

A line starting at an ECEF origin and travelling along the direction vector, expressed in the same Earth-Centered, Earth-Fixed frame as the origin.

The direction need not be normalized; only its orientation is significant. It must be finite and have non-zero magnitude.

ray::Ecef ray{
.origin = {.coords = {4000000, 300000, 5000000}},
.direction = {.x = 1.0, .y = 0.0, .z = 0.0},
};

Variables​

NameDescription
originRay origin in ECEF.
directionDirection in ECEF axes.

Variable Details​

direction​
direction::Ecef direction

Direction in ECEF axes

origin​
position::Ecef origin

Ray origin in ECEF

raptor::ray::Geodetic​

struct Geodetic

Geodetic Ray (origin + direction in local NED)

A line starting at a geodetic origin and travelling along the direction vector, expressed in the local NED frame at that origin.

The direction need not be normalized; only its orientation is significant. It must be finite and have non-zero magnitude.

ray::Geodetic ray{
.origin = {.coords = {51.5, -0.1, 100.0}},
.direction = {.north = 0.0, .east = 0.0, .down = 1.0},
};

Variables​

NameDescription
originRay origin in geodetic coordinates.
directionDirection in local NED frame at origin.

Variable Details​

direction​
direction::Ned direction

Direction in local NED frame at origin

origin​
position::Geodetic origin

Ray origin in geodetic coordinates