Select to view content in your preferred language

Generate ellipse polygon based on 4 mappoints

631
1
09-07-2013 06:50 AM
Labels (1)
ae
by
Frequent Contributor
Hi,

Given 4 mapPoints I would like to generate the ellipse polygon that is enclosed within the 4 mapPoints. Is there any built in functionality that I could use to accomplish this, or does anyone have any idea of how it can be achieved?

Cheers
0 Kudos
1 Reply
AaronHigh
Deactivated User
Assuming the following:

center.X = Width/2
center.Y = Height/2
xRadius = Width/2
yRadius = Height/2

You could create an ellipse by slightly modifying the code posted in this thread (quoted below with my modifications):

http://forums.arcgis.com/threads/77161-draw-circles-on-the-graphics-layer?p=270965&viewfull=1#post27...

private ESRI.ArcGIS.Client.Geometry.Polygon DrawCircle(ESRI.ArcGIS.Client.Geometry.MapPoint center, double radius, int pointsCount = 360) {
 ESRI.ArcGIS.Client.Geometry.Polygon p = new ESRI.ArcGIS.Client.Geometry.Polygon();
 ESRI.ArcGIS.Client.Geometry.PointCollection pcol = new ESRI.ArcGIS.Client.Geometry.PointCollection();
 double slice = 2 * Math.PI / pointsCount;
 for (int i = 0; i <= pointsCount; i++) {
  double rad = slice * i;
  double px = center.X + xRadius * Math.Cos(rad);
  double py = center.Y + YRadius * Math.Sin(rad);
  pcol.Add(new ESRI.ArcGIS.Client.Geometry.MapPoint(px, py));
 }
 p.Rings.Add(pcol);
 return p;
}
0 Kudos