[quoted text, click to view] "Nik Coughlin" <nrkn.com@gmail.com> wrote in message
news:et55aj$p1m$1@aioe.org...
> This won't tell me if the circle intersects one of the lines though will
> it, only if it intersects the polygon as a whole? Which is actually
> something I need to know as well, but I also need to know specifically if
> the circle intersects the lines making up the polygon.
That's true but you will be able to tell if the circle outside the polygon
by getting the regions that don't interset.
[quoted text, click to view] > I'll give it a shot, thanks.
I got
(a2 + 1)x2 + 2abx + b2 - r2 = 0
which can be considered as
dx2 + ex + f = 0
where
d= (a2 + 1)
e = 2ab
f = b2 - r2
you can then use a formula (which I have forgotten) to convert it to
(hx + i)(jx + k) = 0
if h, i, j or k are unreal numbers (roots of negative) then they don't
intersect.
[quoted text, click to view] > I don't mind the circle being inside the polygon (in fact, I want it to
> be!), so long as it doesn't intersect any of the lines.
>
> What I specifically trying to do is allow the circle to be moved around
> within the polygon but not allow it to leave the interior of the polygon.
>
> The polygon may be of any level of complexity and to further complicate
> things, it may have holes in too.
That shouldn't be too much of an issue, just treat the holes as seperate
polygons and do the opposite with them. The other problem you will have is
calculating the position the circle needs to be to just touch the edge. For
example if the circle is right at the centre of the screen and inside the
polygon and then it is moved suddenly to the very left of the screen and
outside the polygon, leaving it at the centre will look poor, you'll need to
determine the edge of the polygon and move it there. Does that make sense?
Michael