Re: overlapping area of two ellipses



On 3 sep, 10:13, fatih.arslan....@xxxxxxxxx wrote:
hello guys,
I have twoellipses, which I know their centers, axis a and axis b and
rotations for each of them. Is there any analytical formula for
calculatingoverlappingregion?
Like Ellips1: center(x,y)=(10,20) axis a=5 axis b=4 rotation=30 degree
Ellps2: center(x,y)=(20,30) axis a=4 axis b=5 rotation=40
degree
(rotation is clockwise)

PS1: Even if I could not find the exact area, a solution which
approximates theoverlappingarea is ok. Because I am writing a C++
code, and I just have to compare theoverlappingareas of differentellipses...So if I can find a reasonable approximation, it is ok...

PS2:If you do not have time or patience to write, you can give me
references...It will be very good...

Thank you

Good day,

Just for the fun, I wrote my own solution with
help of Mathematica's MonteCarlo integration:

overlap[
{a1_,b1_,x1_,y1_,t1_ /; -Pi/2 <= t1 <= Pi/2} /; a1 >= b1,
{a2_,b2_,x2_,y2_,t2_ /; -Pi/2 <= t2 <= Pi/2} /; a2 >= b2]:=
Module[{},
If[x1+a1 <= x2-a2 || y1+a1 <= y2-a2 ||
x2+a2 <= x1-a1 || y2+a2 <= y1-a1, Return[0]];
f[{a_,b_,xc_,yc_,t_},x_,y_]=
(c = Sqrt[a^2 - b^2];
Sqrt[Abs[x - xc - c*Cos[t]]^2 + Abs[y - yc - c*Sin[t]]^2] +
Sqrt[Abs[x - xc + c*Cos[t]]^2 + Abs[y - yc + c*Sin[t]]^2] - 2*a);

f1=f[{a1, b1, x1, y1,t1}, x, y]//N;
f2=f[{a2, b2, x2, y2,t2}, x, y]//N;

in1=f1 <= 0 && x1-a1 <= x <= x1+a1 && y1-a1 <= y <= y1+a1;
in2=f2 <= 0 && x2-a2 <= x <= x2+a2 && y2-a2 <= y <= y2+a2;

xmin = NMinimize[{x,in1 && in2},{x,y}][[1]];
xmax = NMaximize[{x,in1 && in2},{x,y}][[1]];
ymin = NMinimize[{y,in1 && in2},{x,y}][[1]];
ymax = NMaximize[{y,in1 && in2},{x,y}][[1]];

If[xmin >= xmax || ymin >= ymax,0,
NIntegrate[Boole[f1 <=0 && f2 <= 0], {x,xmin, xmax}, {y,ymin, ymax},
Method -> "MonteCarlo", MaxPoints -> 10000]
]
];

Examples:
Identical ellipses:
overlap[{3.,2.,1.,2.,30.Degree},{3.,2.,1.,2.,30.Degree}] //Timing
{1.062,19.091}

Check:
6.Pi
18.8496

No overlapping ellipses:
overlap[{3.,2.,1.,2.,10.Degree},{5.,4.,10.,20.,30.Degree}]//Timing
{0.,0}

Unspecified case:
overlap[{4.,3.,7.,5.,10.Degree},{6.,3.,11.,8.,30.Degree}]//Timing
{1.063,17.196}


V.Astanoff
.



Relevant Pages

  • Re: Constrained quaternion rotation
    ... We are looking to pin down one axis to a World plane instead, ... There are infinitely many correction rotations, ... My Quaternion class has *two* functions named GetClosestX. ... where you can specify angle constraints on t. ...
    (comp.graphics.algorithms)
  • euler angles ,
    ... talks about fixed axis rotation where you rotate an object about each of the ... It then talks about Euler angles, ... rotations always happen along the updated object axes in some order. ...
    (comp.graphics.algorithms)
  • Re: overlapping area of two ellipses
    ... I have two ellipses, which I know their centers, axis a and axis b and ... rotations for each of them. ... approximates the overlapping area is ok. ... ellipses...So if I can find a reasonable approximation, ...
    (comp.graphics.algorithms)
  • overlapping area of two ellipses
    ... I have two ellipses, which I know their centers, axis a and axis b and ... rotations for each of them. ... approximates the overlapping area is ok. ... ellipses...So if I can find a reasonable approximation, ...
    (comp.graphics.algorithms)
  • Quaternions for a continuous sequence of rotations?
    ... that is equivalent to a sequence of specified rotations, ... Now think of a situation where the axis and angle change ...
    (sci.math)

Loading