*/

    public static long
    PointToAngle
    ( int   x,
      int   y )
    {   
        // MAES: note how we don't use &BITS32 here. That is because we know that the maximum possible
        // value of tantoangle is angle
        // This way, we are actually working with vectors emanating from our current position.
        x-= viewx;
        y-= viewy;
        
        if ( (x==0) && (y==0) )
        return 0;

        if (x>= 0)
        {
        // x >=0
        if (y>= 0)
        {
            // y>= 0

            if (x>y)
            {
            // octant 0
            return tantoangle[ SlopeDiv(y,x)];
            }
            else
            {
            // octant 1
            return (ANG90-1-tantoangle[ SlopeDiv(x,y)]);
            }
        }
        else
        {
            // y<0
            y = -y;

            if (x>y)
            {
            // octant 8
            return -tantoangle[SlopeDiv(y,x)];
            }
            else
            {
            // octant 7
            return ANG270+tantoangle[ SlopeDiv(x,y)];
            }
        }
        }
        else
        {
        // x<0
        x = -x;

        if (y>= 0)
        {
            // y>= 0
            if (x>y)
            {
            // octant 3
            return (ANG180-1-tantoangle[ SlopeDiv(y,x)]);
            }
            else
            {
            // octant 2
            return (ANG90+ tantoangle[ SlopeDiv(x,y)]);
            }
        }
        else
        {
            // y<0
            y = -y;

            if (x>y)
            {
            // octant 4
            return (ANG180+tantoangle[ SlopeDiv(y,x)]);
            }
            else
            {
             // octant 5
            return (ANG270-1-tantoangle[ SlopeDiv(x,y)]);
            }
        }
        }
        // This is actually unreachable.
       // return 0;
    }