Re: Rectangle and Circle
- To: mathgroup at smc.vnet.net
- Subject: [mg105550] Re: Rectangle and Circle
- From: dh <dh at metrohm.com>
- Date: Tue, 8 Dec 2009 06:44:49 -0500 (EST)
- References: <hfi936$cj4$1@smc.vnet.net>
Hi, Assuming that you have a rectangle and a circle, and all vertices of the rectangle have a greater distance from the center of the circle than the radius. Then your question boils down to whether some point on an edge has a distance smaller that the radius from the center. Assume for simplicity that the center is at the origin (subtract the origine). Given the 4 vertices: p1={x1,y1},p2,p3,p4. The edge direction: e1=p2-p1,.. Any point on the edge p2...p1 can be written:line1= p1+z1 (p2-p1) with a parameter z1. The direction perpendicular to e1 is: r1={{0,1},{-1,0}}.e1 For the distance of the edge from the origin and the intersection of the corresponding line with line1 we have the equation: eq= r1 + z1(p2-p1) == z2 r1/Norm[r1] we may solve for the parameter z1 and distance z2: {param,dist}={z1,z2}/. Solve[eq,{z1,z2}][[1]] Now, if 0<param<1 and dist> radius, the the circle cuts the edge. Daniel zowtar wrote: > I don't know if here is the right place to ask it, but I don't know > where to go... so... > > I have... > a circle: center point and radius size. > a rectangle: 4 corner points. > > I already know if the circle is inside of the rectangle, or if the > rectangle is inside the circle, or if the case 1 of my image > happens... I want to know if the circle has an intersection with the > rectangle like the case 2 of my image... Any ideia? > > http://img199.imageshack.us/img199/9347/cases.gif >