We don't bite newbies here... much  
PerlMonks 
Re: Some simple 2d gamerelated maths questionsby pajout (Curate) 
on Aug 28, 2008 at 13:03 UTC ( #707467=note: print w/ replies, xml )  Need Help?? 
It is funny to reinvent the wheel sometimes :>)
I suppose that position of the line is constant and the radius of moving circle is constant too. In that case you can define that line by formula (Note: vector (a,b) is perpendicular to the line.) If you consider left side of [1] as function, you can easily see that f(X,Y) = 0 only if point X,Y is on the line, and, f(X,Y) > 0 for each points of one halfplane defined by the line, and, f(X,Y) < 0 for each point of the other halfplane. Consequently, it is directly usable for testing if two points are on the same halfplane. But you want to test something different a bit. Let you construct two helper lines parallel to the [1] line, both in the distance equal to circle radius, g(X,Y) in positive halfplane and h(X,Y) in negative halfplane of the [1], with the same "orientation" of positivity/negativity. You can construct these functions just once when program starts, regardless on the position of the circle. Let (X1,Y1) is position of the circle center before movement and (X2, Y2) is position after movement. Exploring signs of f(X1,Y1), f(X2,Y2), g(X1,Y1), g(X2,Y2), h(X1,Y1), h(X2,Y2) will give you, what do you need. I think it is more suitable than some nonlinear expressions.
In Section
Seekers of Perl Wisdom

