Class: NavMath
Defined in: src/sdk/geo/NavMath.ts:10
Navigational mathematics functions.
Constructors
Constructor
new NavMath():
NavMath
Returns
NavMath
Methods
alongTrack()
staticalongTrack(start,end,pos):number
Defined in: src/sdk/geo/NavMath.ts:278
Calculates the along-track distance from a starting point to another point along a great-circle track running through the starting point.
Parameters
| Parameter | Type | Description |
|---|---|---|
start | LatLonInterface | The start of the great-circle track. |
end | LatLonInterface | The end of the great-circle track. |
pos | LatLonInterface | The point for which to calculate the along-track distance. |
Returns
number
The along-track distance, in nautical miles.
angleToHeading()
staticangleToHeading(angle,turnDirection):number
Defined in: src/sdk/geo/NavMath.ts:234
Converts a degrees north turn circle angle to a degrees north heading.
Parameters
| Parameter | Type | Description |
|---|---|---|
angle | number | The turn circle angle to convert. |
turnDirection | "left" | "right" | The direction of the turn. |
Returns
number
A degrees north heading.
bankAngle()
staticbankAngle(airspeedTrue,radius):number
Defined in: src/sdk/geo/NavMath.ts:66
Gets the required bank angle for a given true airspeed and turn radius.
Parameters
| Parameter | Type | Description |
|---|---|---|
airspeedTrue | number | The true airspeed of the plane, in knots. |
radius | number | The airplane turn radius, in meters. |
Returns
number
The required bank angle, in degrees.
bearingIsBetween()
staticbearingIsBetween(bearing,start,end):boolean
Defined in: src/sdk/geo/NavMath.ts:211
Checks if a degrees north bearing is between two other degrees north bearings.
Parameters
| Parameter | Type | Description |
|---|---|---|
bearing | number | The bearing in degrees north to check. |
start | number | The start bearing in degrees north. |
end | number | The end bearing, in degrees north. |
Returns
boolean
True if the bearing is between the two provided bearings, false otherwise.
calculateArcDistance()
staticcalculateArcDistance(startBearing,endBearing,radius):number
Defined in: src/sdk/geo/NavMath.ts:134
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
| Parameter | Type | Description |
|---|---|---|
startBearing | number | The degrees of the start of the arc. |
endBearing | number | The degrees of the end of the arc. |
radius | number | The radius of the arc, in meters. |
Returns
number
The arc distance.
circleIntersection()
staticcircleIntersection(x1,y1,x2,y2,cx,cy,r,sRef):0|1|2
Defined in: src/sdk/geo/NavMath.ts:152
Calculates the intersection of a line and a circle.
Parameters
| Parameter | Type | Description |
|---|---|---|
x1 | number | The start x of the line. |
y1 | number | The start y of the line. |
x2 | number | The end x of the line. |
y2 | number | The end y of the line. |
cx | number | The circle center x. |
cy | number | The circle center y. |
r | number | The radius of the circle. |
sRef | CircleIntersection | The reference to the solution object to write the solution to. |
Returns
0 | 1 | 2
The number of solutions (0, 1 or 2).
clamp()
staticclamp(val,min,max):number
Defined in: src/sdk/geo/NavMath.ts:22
Clamps a value to a min and max.
Parameters
| Parameter | Type | Description |
|---|---|---|
val | number | The value to clamp. |
min | number | The minimum value to clamp to. |
max | number | The maximum value to clamp to. |
Returns
number
The clamped value.
crossTrack()
staticcrossTrack(start,end,pos):number
Defined in: src/sdk/geo/NavMath.ts:260
Calculates the cross track deviation from the provided leg fixes.
Parameters
| Parameter | Type | Description |
|---|---|---|
start | LatLonInterface | The location of the starting fix of the leg. |
end | LatLonInterface | The location of the ending fix of the leg. |
pos | LatLonInterface | The current plane location coordinates. |
Returns
number
The amount of cross track deviation, in nautical miles.
crossTrackArc()
staticcrossTrackArc(center,radius,pos):number
Defined in: src/sdk/geo/NavMath.ts:367
Gets the cross track distance for a given arc.
Parameters
| Parameter | Type | Description |
|---|---|---|
center | LatLonInterface | The center of the arc. |
radius | number | The radius of the arc, in meters. |
pos | LatLonInterface | The current plane position. |
Returns
number
The cross track distance, in NM.
degreesNorthToPolar()
staticdegreesNorthToPolar(degrees):number
Defined in: src/sdk/geo/NavMath.ts:120
Converts degrees north to polar radians.
Parameters
| Parameter | Type | Description |
|---|---|---|
degrees | number | The degrees to convert. |
Returns
number
The angle radians, in polar.
desiredTrack()
staticdesiredTrack(start,end,pos):number
Defined in: src/sdk/geo/NavMath.ts:296
Calculates the desired track from the provided leg fixes.
Parameters
| Parameter | Type | Description |
|---|---|---|
start | LatLonInterface | The location of the starting fix of the leg. |
end | LatLonInterface | The location of the ending fix of the leg. |
pos | LatLonInterface | The current plane location coordinates. |
Returns
number
The desired track, in degrees true.
desiredTrackArc()
staticdesiredTrackArc(center,turnDirection,pos):number
Defined in: src/sdk/geo/NavMath.ts:313
Gets the desired track for a given arc.
Parameters
| Parameter | Type | Description |
|---|---|---|
center | LatLonInterface | The center of the arc. |
turnDirection | "left" | "right" | The direction of the turn. |
pos | LatLonInterface | The current plane position. |
Returns
number
The desired track.
diffAngle()
staticdiffAngle(a,b):number
Defined in: src/sdk/geo/NavMath.ts:377
Gets the total difference in degrees between two angles.
Parameters
| Parameter | Type | Description |
|---|---|---|
a | number | The first angle. |
b | number | The second angle. |
Returns
number
The difference between the two angles, in degrees, in range -180°...+180°.
getTurnDirection()
staticgetTurnDirection(startCourse,endCourse):"left"|"right"
Defined in: src/sdk/geo/NavMath.ts:102
Get the turn direction for a given course change.
Parameters
| Parameter | Type | Description |
|---|---|---|
startCourse | number | The start course. |
endCourse | number | The end course. |
Returns
"left" | "right"
The turn direction for the course change.
headingToAngle()
staticheadingToAngle(heading,turnDirection):number
Defined in: src/sdk/geo/NavMath.ts:224
Converts a degrees north heading to a degrees north turn circle angle.
Parameters
| Parameter | Type | Description |
|---|---|---|
heading | number | The heading to convert. |
turnDirection | "left" | "right" | The direction of the turn. |
Returns
number
A degrees north turn circle angle.
headingToGroundTrack()
staticheadingToGroundTrack(heading,tas,windDirection,windSpeed):number
Defined in: src/sdk/geo/NavMath.ts:81
Calculates the expected ground track of an airplane for a given heading, true airspeed, and wind conditions.
Parameters
| Parameter | Type | Description |
|---|---|---|
heading | number | The airplane's heading, in degrees. |
tas | number | The airplane's true airspeed, in the same units as windSpeed. |
windDirection | number | The wind direction, in degrees. Wind direction is defined as the heading from which the wind is blowing. |
windSpeed | number | The wind speed, in the same units as tas. |
Returns
number
The expected ground track of an airplane, in degrees, for the specified heading, true airspeed, and wind
conditions. If the specified parameters result in an expected ground speed of zero, then NaN is returned.
napierSide()
staticnapierSide(b,c,beta,gamma):number
Defined in: src/sdk/geo/NavMath.ts:396
Finds side a given sides b, c, and angles beta, gamma.
Parameters
| Parameter | Type | Description |
|---|---|---|
b | number | The length of side b, as a trigonometric ratio. |
c | number | The length of side c, as a trigonometric ratio. |
beta | number | The angle, in radians, of the opposite of side b. |
gamma | number | The angle, in radians, of the opposite of side c |
Returns
number
The length of side a, as a trigonometric ratio.
normal()
staticnormal(course,turnDirection,outVector):void
Defined in: src/sdk/geo/NavMath.ts:407
Calculates a normal vector to a provided course in degrees north.
Parameters
| Parameter | Type | Description |
|---|---|---|
course | number | The course in degrees north. |
turnDirection | "left" | "right" | The direction of the turn to orient the normal. |
outVector | Float64Array | The normal vector for the provided course. |
Returns
void
normalizeHeading()
staticnormalizeHeading(heading):number
Defined in: src/sdk/geo/NavMath.ts:31
Normalizes a heading to a 0-360 range.
Parameters
| Parameter | Type | Description |
|---|---|---|
heading | number | The heading to normalize. |
Returns
number
The normalized heading.
northAngle()
staticnorthAngle(cx,cy,x,y):number
Defined in: src/sdk/geo/NavMath.ts:200
Gets the degrees north that a point lies on a circle.
Parameters
| Parameter | Type | Description |
|---|---|---|
cx | number | The x point of the center of the circle. |
cy | number | The y point of the center of the circle. |
x | number | The x point to get the bearing for. |
y | number | The y point to get the bearing for. |
Returns
number
The angle in degrees north that the point is relative to the center.
percentAlongTrackArc()
staticpercentAlongTrackArc(start,end,center,turnDirection,pos):number
Defined in: src/sdk/geo/NavMath.ts:328
Gets the percentage along the arc path that the plane currently is.
Parameters
| Parameter | Type | Description |
|---|---|---|
start | number | The start of the arc, in degrees north. |
end | number | The end of the arc, in degrees north. |
center | LatLonInterface | The center location of the arc. |
turnDirection | "left" | "right" | The direction of the turn. |
pos | LatLonInterface | The current plane position. |
Returns
number
The percentage along the arc the plane is.
polarToDegreesNorth()
staticpolarToDegreesNorth(radians):number
Defined in: src/sdk/geo/NavMath.ts:111
Converts polar radians to degrees north.
Parameters
| Parameter | Type | Description |
|---|---|---|
radians | number | The radians to convert. |
Returns
number
The angle, in degrees north.
positionAlongArc()
staticpositionAlongArc(start,center,radius,turnDirection,distance,out):GeoPoint
Defined in: src/sdk/geo/NavMath.ts:350
Gets a position given an arc and a distance from the arc start.
Parameters
| Parameter | Type | Description |
|---|---|---|
start | number | The start bearing of the arc. |
center | GeoPoint | The center of the arc. |
radius | number | The radius of the arc. |
turnDirection | "left" | "right" | The turn direction for the arc. |
distance | number | The distance along the arc to get the position for. |
out | GeoPoint | The position to write to. |
Returns
The position along the arc that was written to.
reciprocateHeading()
staticreciprocateHeading(heading):number
Defined in: src/sdk/geo/NavMath.ts:45
Inverts a heading value by adding 180 and normalizing.
Parameters
| Parameter | Type | Description |
|---|---|---|
heading | number | The heading to invert/reciprocate. |
Returns
number
The inverted/reciprocated heading.
turnRadius()
staticturnRadius(airspeedTrue,bankAngle):number
Defined in: src/sdk/geo/NavMath.ts:55
Gets the turn radius for a given true airspeed.
Parameters
| Parameter | Type | Description |
|---|---|---|
airspeedTrue | number | The true airspeed of the plane, in knots. |
bankAngle | number | The bank angle of the plane, in degrees. |
Returns
number
The airplane turn radius, in meters.
windCorrectionAngle()
staticwindCorrectionAngle(course,airspeedTrue,windDirection,windSpeed):number
Defined in: src/sdk/geo/NavMath.ts:246
Calculates the wind correction angle.
Parameters
| Parameter | Type | Description |
|---|---|---|
course | number | The current plane true course. |
airspeedTrue | number | The current plane true airspeed. |
windDirection | number | The direction of the wind, in degrees true. |
windSpeed | number | The current speed of the wind. |
Returns
number
The calculated wind correction angle.