Skip to content

Commit

Permalink
fix: path capture tod (#6827)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjozork authored Mar 4, 2022
1 parent a7fd356 commit 0499bae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/fmgc/src/guidance/lnav/transitions/FixedRadiusTransition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,15 @@ export class FixedRadiusTransition extends Transition {
const tooBigForNext = 'from' in this.nextLeg ? distanceTo(this.nextLeg.from.infos.coordinates, this.nextLeg.to.infos.coordinates) < this.tad + 0.1 : false;
const notLinedUp = Math.abs(prevLegTermDistanceToNextLeg) >= 0.25; // "reasonable" distance

// in some circumstances we revert to a path capture transition where the fixed radius won't work well
const shouldRevert = Math.abs(this.sweepAngle) <= 3
|| Math.abs(this.sweepAngle) > 175
|| this.previousLeg.overflyTermFix || forcedTurn || tooBigForPrevious || tooBigForNext || notLinedUp;

// We do not revert to a path capture if the previous leg was overshot anyway - draw the normal fixed radius turn
const previousLegOvershot = 'overshot' in this.previousLeg && this.previousLeg.overshot;

// in some circumstances we revert to a path capture transition where the fixed radius won't work well
if (Math.abs(this.sweepAngle) <= 3
|| Math.abs(this.sweepAngle) > 175
|| this.previousLeg.overflyTermFix || forcedTurn || (tooBigForPrevious && !previousLegOvershot) || tooBigForNext || notLinedUp
) {
if (shouldRevert && !previousLegOvershot) {
const shouldHaveTad = !this.previousLeg.overflyTermFix && !notLinedUp && tooBigForPrevious;

if (!this.revertTo) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ export class PathCaptureTransition extends Transition {
if ('from' in this.previousLeg) {
const start = this.previousLeg.from.infos.coordinates;
const end = this.previousLeg.to.infos.coordinates;
const length = distanceTo(start, end);

const ratio = this.tad / distanceTo(start, end);
const ratio = (length - this.tad) / length;

initialTurningPoint = getIntermediatePoint(start, end, ratio);
} else {
Expand Down

0 comments on commit 0499bae

Please sign in to comment.