public static int whichSide (Point p1, double theta, Point p2)
    {
        // obtain the point defining the right hand normal (N)
        theta += Math.PI/2;
        int x = p1.x + (int)Math.round(1000*Math.cos(theta)),
            y = p1.y + (int)Math.round(1000*Math.sin(theta));

        // now dot the vector from p1->p2 with the vector from p1->N, if it's positive, we're on
        // the right hand side, if it's negative we're on the left hand side and if it's zero,
        // we're on the line
        return dot(p1.x, p1.y, p2.x, p2.y, x, y);
    }
public static int whichSide ( Point p1 , double theta , Point p2 ) { theta += Math . PI / 2 ; int x = p1 . x + ( int ) Math . round ( 1000 * Math . cos ( theta ) ) , y = p1 . y + ( int ) Math . round ( 1000 * Math . sin ( theta ) ) ; return dot ( p1 . x , p1 . y , p2 . x , p2 . y , x , y ) ; }
Returns less than zero if <code>p2</code> is on the left hand side of the line created by
<code>p1</code> and <code>theta</code> and greater than zero if it is on the right hand
side. In theory, it will return zero if the point is on the line, but due to rounding errors
it almost always decides that it's not exactly on the line.

@param p1 the point on the line whose side we're checking.
@param theta the (logical) angle defining the line.
@param p2 the point that lies on one side or the other of the line.