/*
* this scanner method allows us to make our scanner track our target.
* it will track to where our target is at the moment, and some further
* in case the target has moved.  This way we always get up to the minute
* information on our target
*/

void doScanner() {
        double radarOffset;
        if (getTime() - target.ctime > 4) { 	//if we haven't seen anybody for a bit....
                radarOffset = 360;		//rotate the radar to find a target
        } else {
                //next is the amount we need to rotate the radar by to scan where the target is now
                radarOffset = getRadarHeadingRadians() - absbearing(getX(),getY(),target.x,target.y);

                //this adds or subtracts small amounts from the bearing for the radar
                //to produce the wobbling and make sure we don't lose the target
                if (radarOffset < 0)
                radarOffset -= PI/8;
                else
                radarOffset += PI/8;
        }
        //turn the radar
        setTurnRadarLeftRadians(NormaliseBearing(radarOffset));
}