Skip to main content

Class: NavMath

Defined in: src/sdk/geo/NavMath.ts:9

Navigational mathematics functions.

Constructors

Constructor

new NavMath(): NavMath

Returns

NavMath

Methods

alongTrack()

static alongTrack(start, end, pos): number

Defined in: src/sdk/geo/NavMath.ts:252

Calculates the along-track distance from a starting point to another point along a great-circle track running through the starting point.

Parameters

ParameterTypeDescription
startLatLonInterfaceThe start of the great-circle track.
endLatLonInterfaceThe end of the great-circle track.
posLatLonInterfaceThe point for which to calculate the along-track distance.

Returns

number

The along-track distance, in nautical miles.


angleToHeading()

static angleToHeading(angle, turnDirection): number

Defined in: src/sdk/geo/NavMath.ts:208

Converts a degrees north turn circle angle to a degrees north heading.

Parameters

ParameterTypeDescription
anglenumberThe turn circle angle to convert.
turnDirection"left" | "right"The direction of the turn.

Returns

number

A degrees north heading.


bankAngle()

static bankAngle(airspeedTrue, radius): number

Defined in: src/sdk/geo/NavMath.ts:65

Gets the required bank angle for a given true airspeed and turn radius.

Parameters

ParameterTypeDescription
airspeedTruenumberThe true airspeed of the plane, in knots.
radiusnumberThe airplane turn radius, in meters.

Returns

number

The required bank angle, in degrees.


bearingIsBetween()

static bearingIsBetween(bearing, start, end): boolean

Defined in: src/sdk/geo/NavMath.ts:185

Checks if a degrees north bearing is between two other degrees north bearings.

Parameters

ParameterTypeDescription
bearingnumberThe bearing in degrees north to check.
startnumberThe start bearing in degrees north.
endnumberThe end bearing, in degrees north.

Returns

boolean

True if the bearing is between the two provided bearings, false otherwise.


calculateArcDistance()

static calculateArcDistance(startBearing, endBearing, radius): number

Defined in: src/sdk/geo/NavMath.ts:108

Calculates the distance along an arc on Earth's surface. The arc begins at the intersection of the great circle passing through the center of a circle of radius radius meters in the direction of 'startBearing', and ends at the intersection of the great circle passing through the center of the circle in the direction of 'endBearing', proceeding clockwise (as viewed from above).

Parameters

ParameterTypeDescription
startBearingnumberThe degrees of the start of the arc.
endBearingnumberThe degrees of the end of the arc.
radiusnumberThe radius of the arc, in meters.

Returns

number

The arc distance.


circleIntersection()

static circleIntersection(x1, y1, x2, y2, cx, cy, r, sRef): 0 | 1 | 2

Defined in: src/sdk/geo/NavMath.ts:126

Calculates the intersection of a line and a circle.

Parameters

ParameterTypeDescription
x1numberThe start x of the line.
y1numberThe start y of the line.
x2numberThe end x of the line.
y2numberThe end y of the line.
cxnumberThe circle center x.
cynumberThe circle center y.
rnumberThe radius of the circle.
sRefCircleIntersectionThe reference to the solution object to write the solution to.

Returns

0 | 1 | 2

The number of solutions (0, 1 or 2).


clamp()

static clamp(val, min, max): number

Defined in: src/sdk/geo/NavMath.ts:21

Clamps a value to a min and max.

Parameters

ParameterTypeDescription
valnumberThe value to clamp.
minnumberThe minimum value to clamp to.
maxnumberThe maximum value to clamp to.

Returns

number

The clamped value.


crossTrack()

static crossTrack(start, end, pos): number

Defined in: src/sdk/geo/NavMath.ts:234

Calculates the cross track deviation from the provided leg fixes.

Parameters

ParameterTypeDescription
startLatLonInterfaceThe location of the starting fix of the leg.
endLatLonInterfaceThe location of the ending fix of the leg.
posLatLonInterfaceThe current plane location coordinates.

Returns

number

The amount of cross track deviation, in nautical miles.


crossTrackArc()

static crossTrackArc(center, radius, pos): number

Defined in: src/sdk/geo/NavMath.ts:341

Gets the cross track distance for a given arc.

Parameters

ParameterTypeDescription
centerLatLonInterfaceThe center of the arc.
radiusnumberThe radius of the arc, in meters.
posLatLonInterfaceThe current plane position.

Returns

number

The cross track distance, in NM.


degreesNorthToPolar()

static degreesNorthToPolar(degrees): number

Defined in: src/sdk/geo/NavMath.ts:94

Converts degrees north to polar radians.

Parameters

ParameterTypeDescription
degreesnumberThe degrees to convert.

Returns

number

The angle radians, in polar.


desiredTrack()

static desiredTrack(start, end, pos): number

Defined in: src/sdk/geo/NavMath.ts:270

Calculates the desired track from the provided leg fixes.

Parameters

ParameterTypeDescription
startLatLonInterfaceThe location of the starting fix of the leg.
endLatLonInterfaceThe location of the ending fix of the leg.
posLatLonInterfaceThe current plane location coordinates.

Returns

number

The desired track, in degrees true.


desiredTrackArc()

static desiredTrackArc(center, turnDirection, pos): number

Defined in: src/sdk/geo/NavMath.ts:287

Gets the desired track for a given arc.

Parameters

ParameterTypeDescription
centerLatLonInterfaceThe center of the arc.
turnDirection"left" | "right"The direction of the turn.
posLatLonInterfaceThe current plane position.

Returns

number

The desired track.


diffAngle()

static diffAngle(a, b): number

Defined in: src/sdk/geo/NavMath.ts:351

Gets the total difference in degrees between two angles.

Parameters

ParameterTypeDescription
anumberThe first angle.
bnumberThe second angle.

Returns

number

The difference between the two angles, in degrees, in range -180°...+180°.


getTurnDirection()

static getTurnDirection(startCourse, endCourse): "left" | "right"

Defined in: src/sdk/geo/NavMath.ts:76

Get the turn direction for a given course change.

Parameters

ParameterTypeDescription
startCoursenumberThe start course.
endCoursenumberThe end course.

Returns

"left" | "right"

The turn direction for the course change.


headingToAngle()

static headingToAngle(heading, turnDirection): number

Defined in: src/sdk/geo/NavMath.ts:198

Converts a degrees north heading to a degrees north turn circle angle.

Parameters

ParameterTypeDescription
headingnumberThe heading to convert.
turnDirection"left" | "right"The direction of the turn.

Returns

number

A degrees north turn circle angle.


napierSide()

static napierSide(b, c, beta, gamma): number

Defined in: src/sdk/geo/NavMath.ts:370

Finds side a given sides b, c, and angles beta, gamma.

Parameters

ParameterTypeDescription
bnumberThe length of side b, as a trigonometric ratio.
cnumberThe length of side c, as a trigonometric ratio.
betanumberThe angle, in radians, of the opposite of side b.
gammanumberThe angle, in radians, of the opposite of side c

Returns

number

The length of side a, as a trigonometric ratio.


normal()

static normal(course, turnDirection, outVector): void

Defined in: src/sdk/geo/NavMath.ts:381

Calculates a normal vector to a provided course in degrees north.

Parameters

ParameterTypeDescription
coursenumberThe course in degrees north.
turnDirection"left" | "right"The direction of the turn to orient the normal.
outVectorFloat64ArrayThe normal vector for the provided course.

Returns

void


normalizeHeading()

static normalizeHeading(heading): number

Defined in: src/sdk/geo/NavMath.ts:30

Normalizes a heading to a 0-360 range.

Parameters

ParameterTypeDescription
headingnumberThe heading to normalize.

Returns

number

The normalized heading.


northAngle()

static northAngle(cx, cy, x, y): number

Defined in: src/sdk/geo/NavMath.ts:174

Gets the degrees north that a point lies on a circle.

Parameters

ParameterTypeDescription
cxnumberThe x point of the center of the circle.
cynumberThe y point of the center of the circle.
xnumberThe x point to get the bearing for.
ynumberThe y point to get the bearing for.

Returns

number

The angle in degrees north that the point is relative to the center.


percentAlongTrackArc()

static percentAlongTrackArc(start, end, center, turnDirection, pos): number

Defined in: src/sdk/geo/NavMath.ts:302

Gets the percentage along the arc path that the plane currently is.

Parameters

ParameterTypeDescription
startnumberThe start of the arc, in degrees north.
endnumberThe end of the arc, in degrees north.
centerLatLonInterfaceThe center location of the arc.
turnDirection"left" | "right"The direction of the turn.
posLatLonInterfaceThe current plane position.

Returns

number

The percentage along the arc the plane is.


polarToDegreesNorth()

static polarToDegreesNorth(radians): number

Defined in: src/sdk/geo/NavMath.ts:85

Converts polar radians to degrees north.

Parameters

ParameterTypeDescription
radiansnumberThe radians to convert.

Returns

number

The angle, in degrees north.


positionAlongArc()

static positionAlongArc(start, center, radius, turnDirection, distance, out): GeoPoint

Defined in: src/sdk/geo/NavMath.ts:324

Gets a position given an arc and a distance from the arc start.

Parameters

ParameterTypeDescription
startnumberThe start bearing of the arc.
centerGeoPointThe center of the arc.
radiusnumberThe radius of the arc.
turnDirection"left" | "right"The turn direction for the arc.
distancenumberThe distance along the arc to get the position for.
outGeoPointThe position to write to.

Returns

GeoPoint

The position along the arc that was written to.


reciprocateHeading()

static reciprocateHeading(heading): number

Defined in: src/sdk/geo/NavMath.ts:44

Inverts a heading value by adding 180 and normalizing.

Parameters

ParameterTypeDescription
headingnumberThe heading to invert/reciprocate.

Returns

number

The inverted/reciprocated heading.


turnRadius()

static turnRadius(airspeedTrue, bankAngle): number

Defined in: src/sdk/geo/NavMath.ts:54

Gets the turn radius for a given true airspeed.

Parameters

ParameterTypeDescription
airspeedTruenumberThe true airspeed of the plane, in knots.
bankAnglenumberThe bank angle of the plane, in degrees.

Returns

number

The airplane turn radius, in meters.


windCorrectionAngle()

static windCorrectionAngle(course, airspeedTrue, windDirection, windSpeed): number

Defined in: src/sdk/geo/NavMath.ts:220

Calculates the wind correction angle.

Parameters

ParameterTypeDescription
coursenumberThe current plane true course.
airspeedTruenumberThe current plane true airspeed.
windDirectionnumberThe direction of the wind, in degrees true.
windSpeednumberThe current speed of the wind.

Returns

number

The calculated wind correction angle.