Copyright | (c) 2018 Cedric Liegeois |
---|---|

License | BSD3 |

Maintainer | Cedric Liegeois <ofmooseandmen@yahoo.fr> |

Stability | experimental |

Portability | portable |

Safe Haskell | Safe |

Language | Haskell2010 |

Type and functions for working with delta vectors in different reference frames.

All functions are implemented using the vector-based approached described in Gade, K. (2010). A Non-singular Horizontal Position Representation

## Synopsis

- class Frame a where
- data FrameB
- yaw :: FrameB -> Angle
- pitch :: FrameB -> Angle
- roll :: FrameB -> Angle
- frameB :: ETransform a => Angle -> Angle -> Angle -> a -> Earth -> FrameB
- data FrameL
- wanderAzimuth :: FrameL -> Angle
- frameL :: ETransform a => Angle -> a -> Earth -> FrameL
- data FrameN
- frameN :: ETransform a => a -> Earth -> FrameN
- data Delta
- delta :: Length -> Length -> Length -> Delta
- deltaMetres :: Double -> Double -> Double -> Delta
- dx :: Delta -> Length
- dy :: Delta -> Length
- dz :: Delta -> Length
- data Ned
- ned :: Length -> Length -> Length -> Ned
- nedMetres :: Double -> Double -> Double -> Ned
- north :: Ned -> Length
- east :: Ned -> Length
- down :: Ned -> Length
- bearing :: Ned -> Angle
- elevation :: Ned -> Angle
- slantRange :: Ned -> Length
- deltaBetween :: (ETransform a, Frame c) => a -> a -> (a -> Earth -> c) -> Earth -> Delta
- nedBetween :: ETransform a => a -> a -> Earth -> Ned
- target :: (ETransform a, Frame c) => a -> (a -> Earth -> c) -> Delta -> Earth -> a
- targetN :: ETransform a => a -> Ned -> Earth -> a

# Reference Frames

class for reference frames.

Supported frames:

:: a | |

-> [Vector3d] | rotation matrix to transform vectors decomposed in frame |

## Body frame

Body frame (typically of a vehicle).

- Position: The origin is in the vehicle’s reference point.
- Orientation: The x-axis points forward, the y-axis to the right (starboard) and the z-axis in the vehicle’s down direction.
- Comments: The frame is fixed to the vehicle.

frameB :: ETransform a => Angle -> Angle -> Angle -> a -> Earth -> FrameB Source #

`FrameB`

from given yaw, pitch, roll, position (origin) and earth model.

## Local frame

Local level, Wander azimuth frame.

- Position: The origin is directly beneath or above the vehicle (B), at Earth’s surface (surface of ellipsoid model).
- Orientation: The z-axis is pointing down. Initially, the x-axis points towards north, and the y-axis points towards east, but as the vehicle moves they are not rotating about the z-axis (their angular velocity relative to the Earth has zero component along the z-axis). (Note: Any initial horizontal direction of the x- and y-axes is valid for L, but if the initial position is outside the poles, north and east are usually chosen for convenience.)
- Comments: The L-frame is equal to the N-frame except for the rotation about the z-axis, which is always zero for this frame (relative to Earth). Hence, at a given time, the only difference between the frames is an angle between the x-axis of L and the north direction; this angle is called the wander azimuth angle. The L-frame is well suited for general calculations, as it is non-singular.

wanderAzimuth :: FrameL -> Angle Source #

wander azimuth: angle between x-axis of the frame L and the north direction.

frameL :: ETransform a => Angle -> a -> Earth -> FrameL Source #

`FrameL`

from given wander azimuth, position (origin) and earth model.

## North-East-Down frame

North-East-Down (local level) frame.

- Position: The origin is directly beneath or above the vehicle (B), at Earth’s surface (surface of ellipsoid model).
- Orientation: The x-axis points towards north, the y-axis points towards east (both are horizontal), and the z-axis is pointing down.
- Comments: When moving relative to the Earth, the frame rotates about its z-axis to allow the x-axis to always point towards north. When getting close to the poles this rotation rate will increase, being infinite at the poles. The poles are thus singularities and the direction of the x- and y-axes are not defined here. Hence, this coordinate frame is not suitable for general calculations.

frameN :: ETransform a => a -> Earth -> FrameN Source #

`FrameN`

from given position (origin) and earth model.

# Deltas

delta between position in one of the reference frames.

deltaMetres :: Double -> Double -> Double -> Delta Source #

`Delta`

from given x, y and z length in **metres**.

# Delta in the north, east, down frame

North, east and down delta (thus in frame `FrameN`

).

nedMetres :: Double -> Double -> Double -> Ned Source #

`Ned`

from given north, east and down in **metres**.

bearing :: Ned -> Angle Source #

`bearing v`

computes the bearing in compass angle of the NED vector `v`

from north.

Compass angles are clockwise angles from true north: 0 = north, 90 = east, 180 = south, 270 = west.

elevation :: Ned -> Angle Source #

`elevation v`

computes the elevation of the NED vector `v`

from horizontal (ie tangent to ellipsoid surface).

slantRange :: Ned -> Length Source #

`slantRange v`

computes the distance from origin in the local system of the NED vector `v`

.

# Calculations

deltaBetween :: (ETransform a, Frame c) => a -> a -> (a -> Earth -> c) -> Earth -> Delta Source #

`deltaBetween p1 p2 f e`

computes the exact `Delta`

between the two positions `p1`

and `p2`

in frame `f`

using earth model `e`

.

let p1 = decimalLatLongHeight 1 2 (metres (-3)) let p2 = decimalLatLongHeight 4 5 (metres (-6)) let w = decimalDegrees 5 -- wander azimuth let d = deltaBetween p1 p2 (frameL w) wgs84 d = deltaMetres 359490.579 302818.523 17404.272

nedBetween :: ETransform a => a -> a -> Earth -> Ned Source #

`nedBetween p1 p2 e`

computes the exact `Ned`

vector between the two positions `p1`

and `p2`

, in north, east, and down
using earth model `e`

.

Produced `Ned`

delta is relative to `p1`

: Due to the curvature of Earth and different directions to the North Pole,
the north, east, and down directions will change (relative to Earth) for different places.

Position `p1`

must be outside the poles for the north and east directions to be defined.

let p1 = decimalLatLongHeight 1 2 (metres (-3)) let p2 = decimalLatLongHeight 4 5 (metres (-6)) let d1 = nedBetween p1 p2 wgs84 let d2 = deltaBetween p1 p2 frameN wgs84 north d1 = dx d2 east d1 = dy d2 down d1 = dz d2

target :: (ETransform a, Frame c) => a -> (a -> Earth -> c) -> Delta -> Earth -> a Source #

`target p0 f d e`

computes the target position from position `p0`

and delta `d`

using in frame `f`

and using earth model `e`

.

let p0 = decimalLatLongHeight 49.66618 3.45063 zero let y = decimalDegrees 10 -- yaw let r = decimalDegrees 20 -- roll let p = decimalDegrees 30 -- pitch let d = deltaMetres 3000 2000 100 target p0 (frameB y r p) d wgs84 = decimalLatLongHeight 49.6918016 3.4812669 (metres 6.007)

targetN :: ETransform a => a -> Ned -> Earth -> a Source #

`targetN p0 d e`

computes the target position from position `p0`

and north, east, down `d`

using earth model `e`

.

let p0 = decimalLatLongHeight 49.66618 3.45063 zero targetN p0 (nedMeters 100 200 300) wgs84 = target p0 frameN (deltaMetres 100 200 300) wgs84