public EllipsePieceSegment(FPoint center, float radiusX, float radiusY, float aStart = 0, float aEnd = FloatMath.TAU, CircularDirection dir = CircularDirection.CW) { this.center = center; this.radiusX = radiusX; this.radiusY = radiusY; this.direction = dir; angleStart = aStart; angleEnd = aEnd; if (dir == CircularDirection.CW) { Length = FloatMath.TAU * FloatMath.Sqrt((radiusX * radiusX + radiusY * radiusY) / 2f) * (angleEnd - angleStart) / FloatMath.TAU; Boundings = EllipseHelper.CalculateEllipseSegmentsBoundingBox(center.X, center.Y, radiusX, radiusY, angleStart, angleEnd); } else { // inverted Length = FloatMath.TAU * FloatMath.Sqrt((radiusX * radiusX + radiusY * radiusY) / 2f) * (angleStart - angleEnd) / FloatMath.TAU; Boundings = EllipseHelper.CalculateEllipseSegmentsBoundingBox(center.X, center.Y, radiusX, radiusY, angleEnd, angleStart); } }
public CirclePieceSegment(FPoint center, float radius, float aStart = 0, float aEnd = FloatMath.TAU) { this.center = center; this.radius = radius; if (aStart < aEnd) { direction = CircularDirection.CW; angleStart = aStart; angleEnd = aEnd; } else { direction = CircularDirection.CCW; angleStart = aEnd; angleEnd = aStart; } Length = (2 * FloatMath.PI * radius) * (angleEnd - angleStart) / FloatMath.TAU; directionZero = new Vector2(radius, 0); Boundings = EllipseHelper.CalculateEllipseSegmentsBoundingBox(center.X, center.Y, radius, radius, angleStart, angleEnd); }