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
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()
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
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()
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
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()
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
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()
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
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()
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
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()
static
clamp(val
,min
,max
):number
Defined in: src/sdk/geo/NavMath.ts:21
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()
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
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()
static
crossTrackArc(center
,radius
,pos
):number
Defined in: src/sdk/geo/NavMath.ts:341
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()
static
degreesNorthToPolar(degrees
):number
Defined in: src/sdk/geo/NavMath.ts:94
Converts degrees north to polar radians.
Parameters
Parameter | Type | Description |
---|---|---|
degrees | number | The 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
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()
static
desiredTrackArc(center
,turnDirection
,pos
):number
Defined in: src/sdk/geo/NavMath.ts:287
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()
static
diffAngle(a
,b
):number
Defined in: src/sdk/geo/NavMath.ts:351
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()
static
getTurnDirection(startCourse
,endCourse
):"left"
|"right"
Defined in: src/sdk/geo/NavMath.ts:76
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()
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
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.
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
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()
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
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()
static
normalizeHeading(heading
):number
Defined in: src/sdk/geo/NavMath.ts:30
Normalizes a heading to a 0-360 range.
Parameters
Parameter | Type | Description |
---|---|---|
heading | number | The 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
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()
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
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()
static
polarToDegreesNorth(radians
):number
Defined in: src/sdk/geo/NavMath.ts:85
Converts polar radians to degrees north.
Parameters
Parameter | Type | Description |
---|---|---|
radians | number | The 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
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()
static
reciprocateHeading(heading
):number
Defined in: src/sdk/geo/NavMath.ts:44
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()
static
turnRadius(airspeedTrue
,bankAngle
):number
Defined in: src/sdk/geo/NavMath.ts:54
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()
static
windCorrectionAngle(course
,airspeedTrue
,windDirection
,windSpeed
):number
Defined in: src/sdk/geo/NavMath.ts:220
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.