3
$\begingroup$

I'm wondering how to determine the location of some of the points on the envelope of a family of ellipses? The picture I have is below:

a plot of overlapping ellipses

For each of the individual ellipses, I know how to get the enclosed region using ImplicitRegion, and the code goes like either

ImplicitRegion[Evaluate[a*x^2+b*y^2+cx*y+dy*x+e<=0], {x, y}]

Or

ImplicitRegion[
 Sum[EuclideanDistance[{x, y}, p], {p, foci}] <= majoraxis, {x, y}]]

Supposedly, I'm looking for a function that (1. taking in a point in the region bounded by the envelope, (2. for some theta determine the closest colored point in the angle theta with regards to the input point.

I only need around 20-30 points so that I can run lm and decide whether the envelope is also an ellipse (and I already know how to do this part). Any suggestions on how I can locate points on the envelope?

I tried running RegionIntersection, RegionBoundary and then rasterize it to take random points from the boundary, but this takes more than 1hr on my MacBook for an envelope of 100 ellipses. Both RegionIntersection and RegionBoundary runs very slow, so I'm looking for a more time-wise efficient solution.

$\endgroup$
8
  • $\begingroup$ in what form do you have the ellipses? something like RegionBoundary@*ConvexHullRegion could work! (assuming you want the "outer" envelope. If you want the "inner envelope", something like RegionBoundary@*RegionIntersection could work, assuming you have filled ellipses (which aren't hard to get if you don't)) $\endgroup$
    – thorimur
    Commented Aug 4, 2021 at 22:12
  • $\begingroup$ @thorimur I have the ellipses in formulas, how can I let the contour map be "regions"? $\endgroup$
    – duang
    Commented Aug 4, 2021 at 22:27
  • $\begingroup$ ah i see. Parametric or given by solutions to equations? you could use ParametricRegion or ImplicitRegion, respectively! if you include a couple in your question i can demonstrate in an answer $\endgroup$
    – thorimur
    Commented Aug 4, 2021 at 22:43
  • $\begingroup$ @thorimur thanks!! I think I can use ImplicitRegion for now. $\endgroup$
    – duang
    Commented Aug 4, 2021 at 22:46
  • $\begingroup$ also note that you can take advantage of RandomPoint or MeshCoordinates to get a bunch of explicit coordinates in the resulting region! you might also want to DiscretizeRegion first $\endgroup$
    – thorimur
    Commented Aug 4, 2021 at 22:54

1 Answer 1

4
$\begingroup$

Update

n = 10;
centers = Table[RandomReal[{0, 1/2}, 2], n];
majoraxis = Table[RandomReal[{3, 6}, 2], n];
ellipsoids = MapThread[Ellipsoid, {centers, majoraxis}];
ellipses = MapThread[Circle, {centers, majoraxis}];
interior = RegionIntersection@ellipsoids;
pts = MeshPrimitives[
   RegionIntersection @@@ Subsets[DiscretizeRegion /@ ellipses, {2}] //RegionUnion, 0];
inpts = Select[pts, RegionWithin[interior, #] &];
outpts = Complement[pts, inpts];
Graphics[{{Yellow, DiscretizeRegion@interior}, 
  ellipses, {Cyan, outpts}, {Red, PointSize[Medium], inpts}}]

Or

n = 10;
centers = Table[RandomReal[{0, 1/2}, 2], n];
majoraxis = Table[RandomReal[{3, 6}, 2], n];
ellipsoids = MapThread[Ellipsoid, {centers, majoraxis}];
ellipses = MapThread[Circle, {centers, majoraxis}];
interior = RegionIntersection@ellipsoids;
(* pts=RegionIntersection@@@Subsets[ellipses,{2}] *)
fig = Graphics[ellipses];
pts = Graphics`Mesh`FindIntersections[fig, 
   Graphics`Mesh`AllPoints -> False];
inpts = Select[pts, RegionMember[interior, #] &];
outpts = Complement[pts, inpts];
Graphics[{{Yellow, DiscretizeRegion@interior}, 
  ellipses, {Cyan, Point@outpts}, {Red, PointSize[Medium], 
   Point@inpts}}]

enter image description here

Edit

Clear[ellipses, fig, pts];
ellipses = 
  Table[Circle[RandomReal[{0, 1/2}, 2], RandomReal[{3, 6}, 2]], 10];
fig = Graphics[ellipses];
pts = Graphics`Mesh`FindIntersections[fig, 
   Graphics`Mesh`AllPoints -> False];
Show[fig, Graphics[{PointSize[Medium], Red, Point[pts]}]]

Or

Clear[ellipses, pts];
ellipses = 
  Table[Circle[RandomReal[{0, 1/2}, 2], RandomReal[{3, 6}, 2]], 10];
pts = Cases[
   Table[RegionIntersection[ellipses[[i]], ellipses[[j]]], {i, 
     Length@ellipses}, {j, i - 1}], {x_Real, y_Real} :> {x, y}, 
   Infinity];
Graphics[{ellipses, PointSize[Medium], Red, Point[pts]}]

enter image description here

Original

Do you want such points?

reg = ImplicitRegion[4 x^2 + 3 y^2 - 3 x*y == 4, {x, y}];
pts = RandomPoint[reg, 5]
RegionMember[reg] /@ pts
RegionPlot[reg, Epilog -> {PointSize[Large], Red, Point[pts]}]

{True, True, True, True, True}

enter image description here

$\endgroup$
4
  • $\begingroup$ I'm looking for points on the envelop of the ellipses, like the inner boundary of the intersections of a bunch of ellipses. $\endgroup$
    – duang
    Commented Aug 5, 2021 at 15:54
  • $\begingroup$ @duang Please see the updated. $\endgroup$
    – cvgmt
    Commented Aug 6, 2021 at 0:19
  • $\begingroup$ thanks for the update. I would want points only on the innermost curve tho, is there any way to select those only? $\endgroup$
    – duang
    Commented Aug 6, 2021 at 2:38
  • $\begingroup$ @duang see another update. $\endgroup$
    – cvgmt
    Commented Aug 6, 2021 at 9:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.