Britbot
static double Britbot.Navigator.CalcDistFromLine ( Location  point,
Location  linePoint,
HeadingVector  dir 
) [inline, static]

calculates distance (in turns) from ship's trajectory to a given island location (point) uses the calculation in calculation sheet 3

Parameters:
pointthe point outside the trajectory (island)
linePointthe point on the trajectory (ship)
dirdirection of the line (direction of the ship)
Returns:

Definition at line 161 of file Navigator.cs.

        {
            //first check if no direction
            if (dir.NormSquared() == 0)
                return Bot.Game.Distance(point, linePoint);

            //TODO fix this - Matan Kom
            //Find the difference vector between the point and the line point
            HeadingVector dif = HeadingVector.CalcDifference(point, linePoint);
            //find the minimum t parameter
            double tMin = (-1 / dir.NormSquared()) * dir * dif;

            //calculating actual distance (see calculation)
            return (dif + tMin * dir).Norm();
            ;
        }