Question about isABSameAsVehicleHeading in CABLine.cs

Is there a category on this forum for discussions about AOG code and function? I’m helping someone understand the logic in the Stanley AB line algorithm, so I was going through the code to document it. And have a question about it.

This is a question about isABSameAsVehicleHeading in CABLine. I understand what this variable is used for. It is used for several things including adjusting the ABLine for the tool offset, making sure the cross track error display has the right sign, and in calculating the heading delta to be used by the Stanley algorithm. Starting in line 359, the tool offset is used to create the closest current AB line, with the tool offset added or subtracted depending on if the vehicle is traveling in the same general heading as the AB line (heading from A->B). In other words should the line be shifted left or right. However the isABSameAsVehicleHeading variable is not actually computed until later in the code around line 398 where the difference in vehicle heading vs A->B heading is determined. Thus it’s possible that for a brief moment under certain circumstances–for example, if you turned off the AB Line mode, turned 180 degrees, and then turned it on again–the last value of isABSameAsVehicleHeading might not be right in line 359, and the offset would be on the wrong side of the line. This would only be the case for one iteration.

Question, Brian. Do I understand this right? Should the abFixDelta heading and isABSameAsVehicleHeading be computed before that first if statement in line 359?