Expand description
Local Cartesian frames and vectors typed by frame and unit.
Near a point, positions and velocities are naturally expressed in a local Cartesian frame — NED, ENU, or the vessel’s forward-right-down. Mixing frames is the classic sign error; adding a velocity to a displacement the classic unit error.
Vector3<F, U> carries both frame F and unit U in its type:
Vector3<Ned, Distance> and Vector3<Enu, Distance> cannot be added, nor
Vector3<Ned, Distance> and Vector3<Ned, Speed>. The same approach as
Direction<F>, in three dimensions:
ⓘ
use kinavis_kernel::local::{Enu, Ned, Vector3};
use kinavis_kernel::Distance;
let ned: Vector3<Ned, Distance> = Vector3::new(Distance::ZERO, Distance::ZERO, Distance::ZERO);
let enu: Vector3<Enu, Distance> = Vector3::new(Distance::ZERO, Distance::ZERO, Distance::ZERO);
let _ = ned + enu; // mismatched types: `Ned` is not `Enu`A LocalFrame is a NED frame anchored at a point: it converts a
GeodeticPoint to a NED displacement from its origin and back, via
EcefPoint on a named Ellipsoid.
use kinavis_kernel::geodesy::{Ellipsoid, GeodeticPoint, Height};
use kinavis_kernel::local::LocalFrame;
use kinavis_kernel::{Distance, Position};
let origin = GeodeticPoint::new(
"50°45.3'N 001°20.0'W".parse::<Position>()?,
Height::above_ellipsoid(Distance::ZERO),
);
let frame = LocalFrame::at(origin, &Ellipsoid::WGS84)?;
// A point one minute of latitude north of the origin.
let north = GeodeticPoint::new(
"50°46.3'N 001°20.0'W".parse::<Position>()?,
Height::above_ellipsoid(Distance::ZERO),
);
let ned = frame.ned_of(north)?;
// A minute of latitude on the ellipsoid at 50°N is 1854 m, not the
// sphere's 1852.
assert!((ned.north().metres() - 1854.1).abs() < 0.5);
assert!(ned.east().metres().abs() < 1e-6);
// The Earth curves away under a straight line: the point is slightly
// below the origin's horizontal plane.
assert!(ned.down().metres() > 0.0 && ned.down().metres() < 0.3);Structs§
- Body
- Forward, right, down: the vessel body frame.
- Enu
- East, north, up: surveying and mapping frame.
- Local
Frame - NED frame anchored at a point.
- Ned
- North, east, down: the navigation frame.
- Vector3
- Three components of one quantity in one frame.
Traits§
- Vector
Frame - Frame of a
Vector3. - Vector
Unit - Quantity carried by each
Vector3component.