Lets assume that the boat is at location A and it wants to sail to location B. The easiest logic is to keep heading to B. The problem with this approach is that the boat has no way of measuring its accuracy on keeping to the path to B, apart from its distance to B. If the boat has to tack along the path the boat requires more information.
One trick is to remember the last waypoint A and use the track AB to measure progress. Lets assume the boat is now at location C. The navigation path has the formulae to calculate the cross track distance and alongtrack distance. Thus progress can be measured and also the deviation away from the direct route.Spherical DistanceAB Spherical Bearing Spherical Waypoint Spherical Cross Track Spherical Along Track