Table of Contents

Struct Arc

Namespace
Xui.Core.Curves2D
Assembly
Core.dll

Represents a circular or elliptical arc defined by a center point, radii, rotation, and sweep angles.

public readonly struct Arc : ICurve
Implements
Inherited Members

Remarks

Arcs are useful for describing elliptical curves in vector graphics, layout paths, and stroke outlines. They interpolate smoothly from StartAngle to EndAngle, optionally applying rotation and winding direction.

Constructors

Arc(Point, NFloat, NFloat, NFloat, NFloat, NFloat, Winding)

Initializes a new Arc with the given center, radii, rotation, angles, and winding direction.

public Arc(Point center, NFloat rx, NFloat ry, NFloat rotation, NFloat startAngle, NFloat endAngle, Winding winding = Winding.ClockWise)

Parameters

center Point

The center point of the arc's ellipse.

rx NFloat

The horizontal radius.

ry NFloat

The vertical radius.

rotation NFloat

The clockwise rotation in radians applied to the ellipse.

startAngle NFloat

The start angle of the arc in radians (before rotation).

endAngle NFloat

The end angle of the arc in radians (before rotation).

winding Winding

Whether the arc is drawn clockwise or counter-clockwise.

Fields

Center

The center point of the arc's ellipse.

public readonly Point Center

Field Value

Point

EndAngle

The angle (in radians) at which the arc ends, before rotation is applied.

public readonly NFloat EndAngle

Field Value

NFloat

RadiusX

The horizontal radius of the arc.

public readonly NFloat RadiusX

Field Value

NFloat

RadiusY

The vertical radius of the arc.

public readonly NFloat RadiusY

Field Value

NFloat

Rotation

The clockwise rotation (in radians) applied to the arc relative to the X axis.

public readonly NFloat Rotation

Field Value

NFloat

StartAngle

The angle (in radians) at which the arc starts, before rotation is applied.

public readonly NFloat StartAngle

Field Value

NFloat

Winding

Specifies whether the arc is drawn clockwise or counter-clockwise.

public readonly Winding Winding

Field Value

Winding

Properties

this[NFloat]

Gets the interpolated point on the arc at the specified parameter t.

public Point this[NFloat t] { get; }

Parameters

t NFloat

A normalized value from 0 to 1 representing the progression along the arc.

Property Value

Point

SweepAngle

Gets the signed sweep angle of the arc, in radians. Adjusts automatically for the specified Winding.

public NFloat SweepAngle { get; }

Property Value

NFloat

Methods

Evaluate(NFloat)

Evaluates the arc at a normalized parameter t, returning the corresponding point.

public Point Evaluate(NFloat t)

Parameters

t NFloat

A normalized value in the range [0, 1].

Returns

Point

The corresponding point on the rotated ellipse arc.

EvaluateAtAngle(NFloat)

Evaluates the position on the ellipse at a given angle θ (in radians), relative to the unrotated ellipse center.

public Point EvaluateAtAngle(NFloat θ)

Parameters

θ NFloat

The angle in radians, measured from the X axis of the unrotated ellipse. This is not a normalized parameter like t, but an absolute angle used in parametric arc equations.

Returns

Point

The corresponding Point on the arc's ellipse at the given angle, after applying the arc's rotation and translating from its center.

Remarks

The point is computed using the parametric equation of an axis-aligned ellipse: (x, y) = (rx * cos(θ), ry * sin(θ)), then rotated by Rotation and translated to Center. This method is useful when working directly with angle-based metrics like vertical extrema (e.g., θ = π/2 or 3π/2).

Length()

Approximates the arc length using uniform sampling with 16 segments.

public NFloat Length()

Returns

NFloat

The approximate total arc length.

Length(NFloat)

Approximates the arc length using recursive adaptive subdivision.

public NFloat Length(NFloat flatness)

Parameters

flatness NFloat

The maximum allowed error per segment for arc approximation.

Returns

NFloat

The computed arc length within the specified flatness tolerance.

Lerp(NFloat)

Computes the interpolated point on the arc at a given parameter t.

public Point Lerp(NFloat t)

Parameters

t NFloat

A normalized value in the range [0, 1].

Returns

Point

Tangent(NFloat)

Computes the tangent vector at parameter t on the arc.

public Vector Tangent(NFloat t)

Parameters

t NFloat

A normalized value in the range [0, 1].

Returns

Vector

The normalized tangent vector at the evaluated point on the arc.

ToArc3Segments(Span<Arc3Point>, out int)

Splits this arc into a series of Arc3Point segments, each spanning ≤ 90° and aligned so that one edge is axis-aligned.

public void ToArc3Segments(Span<Arc3Point> buffer, out int count)

Parameters

buffer Span<Arc3Point>

A span to receive the output segments. Must have space for up to 4 entries.

count int

The number of segments written to buffer.

Remarks

This method ensures consistent arc tessellation by aligning segment edges with X or Y axes and bounding each by ≤ 90°, suitable for round rects or shader-compatible curves.

ToEndpointArc()

Converts this arc to an endpoint-parameterized ArcEndpoint representation.

public ArcEndpoint ToEndpointArc()

Returns

ArcEndpoint

An ArcEndpoint structure that approximates this arc using endpoint-based parametrization.

Remarks

This method generates a single arc segment between the start and end points of the original arc, preserving the sweep direction and determining whether the arc is the larger of the two possible segments. If the arc forms a complete circle (i.e., the start and end points match and the sweep covers 360°), the endpoint position is nudged slightly to avoid rendering ambiguities in formats that do not support full-circle arcs directly.

ToEndpointArcs()

Converts this arc to one or two endpoint-parameterized arcs, depending on the arc's sweep angle.

public (ArcEndpoint, ArcEndpoint?) ToEndpointArcs()

Returns

(ArcEndpoint, ArcEndpoint?)

A tuple of one or two ArcEndpoint instances that collectively represent the same elliptical arc:

  • Item1 – The first arc segment (always non-null).
  • Item2 – The second arc segment if the arc is split, or null if the arc fits in a single segment.

Remarks

If the arc forms a complete or nearly complete circle (i.e., the sweep angle approaches ±360° and the start and end points match), the arc is split into two half-circle segments to avoid rendering issues in formats that do not support full-circle arcs directly. Otherwise, a single ArcEndpoint is returned with appropriate flags set for direction and size.