Skip to main content

Class: NavMath

Navigational mathematics functions.

Constructors

constructor

new NavMath(): NavMath

Returns

NavMath

Methods

alongTrack

alongTrack(start, end, pos): number

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

Parameters

NameTypeDescription
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.

Defined in

src/sdk/geo/NavMath.ts:252


angleToHeading

angleToHeading(angle, turnDirection): number

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

Parameters

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

Returns

number

A degrees north heading.

Defined in

src/sdk/geo/NavMath.ts:208


bankAngle

bankAngle(airspeedTrue, radius): number

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

Parameters

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

Returns

number

The required bank angle, in degrees.

Defined in

src/sdk/geo/NavMath.ts:65


bearingIsBetween

bearingIsBetween(bearing, start, end): boolean

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

Parameters

NameTypeDescription
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.

Defined in

src/sdk/geo/NavMath.ts:185


calculateArcDistance

calculateArcDistance(startBearing, endBearing, radius): number

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

NameTypeDescription
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.

Defined in

src/sdk/geo/NavMath.ts:108


circleIntersection

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

Calculates the intersection of a line and a circle.

Parameters

NameTypeDescription
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 | 2 | 1

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

Defined in

src/sdk/geo/NavMath.ts:126


clamp

clamp(val, min, max): number

Clamps a value to a min and max.

Parameters

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

Returns

number

The clamped value.

Defined in

src/sdk/geo/NavMath.ts:21


crossTrack

crossTrack(start, end, pos): number

Calculates the cross track deviation from the provided leg fixes.

Parameters

NameTypeDescription
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.

Defined in

src/sdk/geo/NavMath.ts:234


crossTrackArc

crossTrackArc(center, radius, pos): number

Gets the cross track distance for a given arc.

Parameters

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

Returns

number

The cross track distance, in NM.

Defined in

src/sdk/geo/NavMath.ts:341


degreesNorthToPolar

degreesNorthToPolar(degrees): number

Converts degrees north to polar radians.

Parameters

NameTypeDescription
degreesnumberThe degrees to convert.

Returns

number

The angle radians, in polar.

Defined in

src/sdk/geo/NavMath.ts:94


desiredTrack

desiredTrack(start, end, pos): number

Calculates the desired track from the provided leg fixes.

Parameters

NameTypeDescription
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.

Defined in

src/sdk/geo/NavMath.ts:270


desiredTrackArc

desiredTrackArc(center, turnDirection, pos): number

Gets the desired track for a given arc.

Parameters

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

Returns

number

The desired track.

Defined in

src/sdk/geo/NavMath.ts:287


diffAngle

diffAngle(a, b): number

Gets the total difference in degrees between two angles.

Parameters

NameTypeDescription
anumberThe first angle.
bnumberThe second angle.

Returns

number

The difference between the two angles, in degrees.

Defined in

src/sdk/geo/NavMath.ts:351


getTurnDirection

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

Get the turn direction for a given course change.

Parameters

NameTypeDescription
startCoursenumberThe start course.
endCoursenumberThe end course.

Returns

"left" | "right"

The turn direction for the course change.

Defined in

src/sdk/geo/NavMath.ts:76


headingToAngle

headingToAngle(heading, turnDirection): number

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

Parameters

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

Returns

number

A degrees north turn circle angle.

Defined in

src/sdk/geo/NavMath.ts:198


napierSide

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

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

Parameters

NameTypeDescription
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.

Defined in

src/sdk/geo/NavMath.ts:370


normal

normal(course, turnDirection, outVector): void

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

Parameters

NameTypeDescription
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

Defined in

src/sdk/geo/NavMath.ts:381


normalizeHeading

normalizeHeading(heading): number

Normalizes a heading to a 0-360 range.

Parameters

NameTypeDescription
headingnumberThe heading to normalize.

Returns

number

The normalized heading.

Defined in

src/sdk/geo/NavMath.ts:30


northAngle

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

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

Parameters

NameTypeDescription
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.

Defined in

src/sdk/geo/NavMath.ts:174


percentAlongTrackArc

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

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

Parameters

NameTypeDescription
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.

Defined in

src/sdk/geo/NavMath.ts:302


polarToDegreesNorth

polarToDegreesNorth(radians): number

Converts polar radians to degrees north.

Parameters

NameTypeDescription
radiansnumberThe radians to convert.

Returns

number

The angle, in degrees north.

Defined in

src/sdk/geo/NavMath.ts:85


positionAlongArc

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

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

Parameters

NameTypeDescription
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.

Defined in

src/sdk/geo/NavMath.ts:324


reciprocateHeading

reciprocateHeading(heading): number

Inverts a heading value by adding 180 and normalizing.

Parameters

NameTypeDescription
headingnumberThe heading to invert/reciprocate.

Returns

number

The inverted/reciprocated heading.

Defined in

src/sdk/geo/NavMath.ts:44


turnRadius

turnRadius(airspeedTrue, bankAngle): number

Gets the turn radius for a given true airspeed.

Parameters

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

Returns

number

The airplane turn radius, in meters.

Defined in

src/sdk/geo/NavMath.ts:54


windCorrectionAngle

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

Calculates the wind correction angle.

Parameters

NameTypeDescription
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.

Defined in

src/sdk/geo/NavMath.ts:220