Re: find two ellipse enclose area?
- From: ellieandrogerxyzzy@xxxxxxxxxxxxxxxxxxxxxx (Roger Stafford)
- Date: Sat, 22 Oct 2005 19:25:06 GMT
In article
<ellieandrogerxyzzy-2210051048060001@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
ellieandrogerxyzzy@xxxxxxxxxxxxxxxxxxxxxx (Roger Stafford) wrote:
> In article <ef1908e.1@xxxxxxxxxxxxxxxx>, Thinkpad <allio@xxxxxxxxx> wrote:
>
> > Thanks for your reply quickly.
> > These two ellipse equations as follows:
> >
> > A ellipse: [(x-x1)cos(theta1)+(y-y1)sin(theta1)]^2/(a^2) +
> > [(x-x1)sin(theta1)+(y-y1)cos(theta1)]^2/(b^2) = 1.
> >
> > B ellipse: [(x-x2)cos(theta2)+(y-y2)sin(theta2)]^2/(c^2) +
> > [(x-x2)sin(theta2)+(y-y2)cos(theta2)]^2/(d^2) = 1.
> > x1,y1,a,b,x2,y2,c,d,theta1,theta2 are given.
> >
> > I answer your comment:
> > 1. maybe, if theta1/theta2 equal zero, but always don't equal zero.
> > 2. no. x1 isn't equal to x2, and y1 isn't equal to y2.
> > 3. only intersect in two points.
> > 5. These two ellipse have angle(theta) between x/y axes.
> --------------
> Hello Allio,
>
> These are general ellipses with arbitrary orientations and therefore
> present the greatest challenge. There would be a large amount of work to
> do to create a truly robust and automatic method of solving your problem.
> All I can do is give you a sketchy idea of how to proceed in a somewhat
> unsophisticated solution.
>
> By the way, aren't you missing a couple of minus signs in your
> equations? Shouldn't they be:
>
> A ellipse: [(x-x1)cos(theta1)+(y-y1)sin(theta1)]^2/(a^2) +
> [-(x-x1)sin(theta1)+(y-y1)cos(theta1)]^2/(b^2) = 1 ,
>
> B ellipse: [(x-x2)cos(theta2)+(y-y2)sin(theta2)]^2/(c^2) +
> [-(x-x2)sin(theta2)+(y-y2)cos(theta2)]^2/(d^2) = 1 ?
>
> If so, you can generate the first of these parametrically with
> closely-spaced points as:
>
> m = 1000; % <== Choose a suitably large value for close spacing
> p = linspace(0,2*pi,m)';
> u = a*cos(p); v = b*sin(p);
> x = x1 + u*cos(theta1) - v*sin(theta1);
> y = y1 + u*sin(theta1) + v*cos(theta1);
>
> and similarly with the second ellipse. These can be used to make plots.
>
> I won't attempt to tell you how to determine the points where these
> curves cross. The analytic solution is too horrible to contemplate, as
> you would see if you used matlab's 'solve' function. From their plots you
> could make an approximation visually. Perhaps a 2D Newton-Raphson method
> could then be used to get better accuracy using the values obtained from
> the plots as initial estimates.
>
> One way or another, you need to find a pathway of closely-spaced points
> which encircle the region you are interested in. This will consist of two
> (or four) segments excised from the above two parametric curves and joined
> at the intersection points. Once this pathway has been found in terms of
> two column vectors x and y, you can get the region's approximate area as:
>
> xs = [x(2:end);x(1)]; ys = [y(2:end);y(1)];
> area = abs(1/2*sum(x.*ys-xs.*y));
>
> This is actually the area of the polygon connecting the x,y points. The
> more numerous the points, the more accurate the approximation to the
> elliptical region.
>
> Roger Stafford
------------------
Hello Allio,
Presumably the region you are interested in is that which lies inside
both ellipses. It has occurred to me that you could simplify the problem
of determining intersections if you computed a flag vector along with the
parametric generation of an ellipse indicating if that point lies inside
the other ellipse. Thus, in the first curve you would have:
m = 1000; % <== Choose a suitably large value for close spacing
p = linspace(0,2*pi,m)';
u = a*cos(p); v = b*sin(p);
x = x1 + u*cos(theta1) - v*sin(theta1);
y = y1 + u*sin(theta1) + v*cos(theta1);
flag1 = ( ((x-x2)*cos(theta2)+(y-y2)*sin(theta2)).^2/c^2 + ...
(-(x-x2)*sin(theta2)+(y-y2)*cos(theta2)).^2/d^2 <= 1);
and the second curve would be similarly accompanied by an analogous flag2.
Then, only the segments of each curve would be selected for which the
accompanying flag is true. This would give you two (or possibly four)
segments to join from the two elliptical curves. It would only be
necessary to ensure that at each junction the endpoint of one segment lies
in the immediate vicinity of the initial point of the next segment.
Incidentally, a single segment on a curve could well start at some point
prior to the end of the parametric vector and continue from its beginning
- that is, the end and beginning of the vector might both lie inside the
other ellipse. You may want to take that possibility into account and
rejoin it into a single segment before you assemble the segments.
It seems to me that, with a little care and good programming, you could
entirely automate all the above into a reasonably robust procedure. I
leave that to you, however.
(Remove "xyzzy" and ".invalid" to send me email.)
Roger Stafford
.
- References:
- Re: find two ellipse enclose area?
- From: Roger Stafford
- Re: find two ellipse enclose area?
- From: Thinkpad
- Re: find two ellipse enclose area?
- Prev by Date: Re: Peak Alignment
- Next by Date: integration in matlab
- Previous by thread: Re: find two ellipse enclose area?
- Next by thread: Algebraic loop errors in Simulink
- Index(es):
Relevant Pages
|