public static FRectangle CalculateEllipseSegmentsBoundingBox(float cx, float cy, float rx, float ry, float aStart, float aEnd) { float minX = 0; float minY = 0; float maxX = 0; float maxY = 0; if (FloatMath.ArcContainsAngle(aStart, aEnd, FloatMath.RAD_POS_270)) { minY = -ry; } else { minY = FloatMath.Min(minY, GetPointYOnEllipse(0, 0, rx, ry, aStart)); minY = FloatMath.Min(minY, GetPointYOnEllipse(0, 0, rx, ry, aEnd)); } if (FloatMath.ArcContainsAngle(aStart, aEnd, FloatMath.RAD_POS_090)) { maxY = +ry; } else { maxY = FloatMath.Max(maxY, GetPointYOnEllipse(0, 0, rx, ry, aStart)); maxY = FloatMath.Max(maxY, GetPointYOnEllipse(0, 0, rx, ry, aEnd)); } if (FloatMath.ArcContainsAngle(aStart, aEnd, FloatMath.RAD_POS_180)) { minX = -rx; } else { minX = FloatMath.Min(minX, GetPointXOnEllipse(0, 0, rx, ry, aStart)); minX = FloatMath.Min(minX, GetPointXOnEllipse(0, 0, rx, ry, aEnd)); } if (FloatMath.ArcContainsAngle(aStart, aEnd, FloatMath.RAD_000)) { maxX = +rx; } else { maxX = FloatMath.Max(maxX, GetPointXOnEllipse(0, 0, rx, ry, aStart)); maxX = FloatMath.Max(maxX, GetPointXOnEllipse(0, 0, rx, ry, aEnd)); } return(new FRectangle(cx + minX, cy + minY, maxX - minX, maxY - minY)); }