# Xui.Core.Curves3D

Assembly: **Xui.Core** · [C# declarations](index.cs) · [Assembly overview](../index.md)

## Types

- [`class Bezier3`](#api-ddee03367ffaaa87)
- [`readonly struct CubicBezier3`](#api-bc7a3a4982dbbf11)
- [`interface ICurve3`](#api-e04ef643af8d70ef)
- [`readonly struct LinearBezier3`](#api-45d7d7129fdc3798)
- [`readonly struct QuadraticBezier3`](#api-5cc9868b494141a7)

<a id="api-ddee03367ffaaa87"></a>

## `class Bezier3`

Provides factory methods for constructing 3D B&#233;zier curves.

```csharp
public static class Bezier3
{
    public static LinearBezier3 Linear(Point3 p0, Point3 p1);
    public static QuadraticBezier3 Quadratic(Point3 p0, Point3 p1, Point3 p2);
    public static CubicBezier3 Cubic(Point3 p0, Point3 p1, Point3 p2, Point3 p3);
}
```

<a id="api-dbc4f4ce75d8f9fd"></a>

### [`CubicBezier3 Bezier3.Cubic(Point3 p0, Point3 p1, Point3 p2, Point3 p3)`](#api-dbc4f4ce75d8f9fd)


```csharp
public static CubicBezier3 Cubic(Point3 p0, Point3 p1, Point3 p2, Point3 p3);
```

Creates a cubic (degree-3) B&#233;zier curve with two control points.

- **`p0`** — The start point.

- **`p1`** — The first control point.

- **`p2`** — The second control point.

- **`p3`** — The end point.

<a id="api-a5083a6b041761e1"></a>

### [`LinearBezier3 Bezier3.Linear(Point3 p0, Point3 p1)`](#api-a5083a6b041761e1)


```csharp
public static LinearBezier3 Linear(Point3 p0, Point3 p1);
```

Creates a linear (degree-1) B&#233;zier curve — a straight line from `p0` to `p1`.

<a id="api-22482e8db4f4abd7"></a>

### [`QuadraticBezier3 Bezier3.Quadratic(Point3 p0, Point3 p1, Point3 p2)`](#api-22482e8db4f4abd7)


```csharp
public static QuadraticBezier3 Quadratic(Point3 p0, Point3 p1, Point3 p2);
```

Creates a quadratic (degree-2) B&#233;zier curve with one control point.

- **`p0`** — The start point.

- **`p1`** — The control point.

- **`p2`** — The end point.


<a id="api-bc7a3a4982dbbf11"></a>

## `readonly struct CubicBezier3`

Represents a cubic (degree-3) B&#233;zier curve in 3D space, defined by a start point, two control points, and an end point.

A cubic B&#233;zier provides smooth interpolation from [`Xui.Core.Curves3D.CubicBezier3.P0`](../xui-core-curves3d/index.md#api-029ecde2e16bae7b) to [`Xui.Core.Curves3D.CubicBezier3.P3`](../xui-core-curves3d/index.md#api-f2677b9bb764d7ab), shaped by the two interior control points [`Xui.Core.Curves3D.CubicBezier3.P1`](../xui-core-curves3d/index.md#api-05bfe6f137ccd1e7) and [`Xui.Core.Curves3D.CubicBezier3.P2`](../xui-core-curves3d/index.md#api-85ef5f8bb37bf35b). Points are computed using De Casteljau&#39;s algorithm for numerical stability. This is the standard curve type for 3D animation paths and splines.

```csharp
public readonly struct CubicBezier3 : ICurve3
{
    public readonly Point3 P0;
    public readonly Point3 P1;
    public readonly Point3 P2;
    public readonly Point3 P3;
    public CubicBezier3(Point3 p0, Point3 p1, Point3 p2, Point3 p3);
    public Point3 Lerp(float t);
    public Vector3 Tangent(float t);
    public Point3 this[float t] { get; }

    public float Length();
    public float Length(float precision);
    public (CubicBezier3 left, CubicBezier3 right) Subdivide(float t);
    public QuadraticBezier3 QuadraticApproximation { get; }

    public override string ToString();
}
```

<a id="api-789f5e9f59d2c561"></a>

### [`CubicBezier3.CubicBezier3(Point3 p0, Point3 p1, Point3 p2, Point3 p3)`](#api-789f5e9f59d2c561)


```csharp
public CubicBezier3(Point3 p0, Point3 p1, Point3 p2, Point3 p3);
```

Initializes a new [`Xui.Core.Curves3D.CubicBezier3`](../xui-core-curves3d/index.md#api-bc7a3a4982dbbf11) with the specified control points.

<a id="api-47d6d472041ad332"></a>

### [`Point3 CubicBezier3.this[float t]`](#api-47d6d472041ad332)


```csharp
public Point3 this[float t] { get; }
```

Evaluates the curve at the given parameter `t`. Alias for [`Xui.Core.Curves3D.ICurve3.Lerp(System.Single)`](../xui-core-curves3d/index.md#api-7cf8ddd08adaf342).

<a id="api-1665d4b93f521e38"></a>

### [`float CubicBezier3.Length()`](#api-1665d4b93f521e38)


```csharp
public float Length();
```

Approximates the arc length using 16 uniform samples.

<a id="api-fc1f63bec1873436"></a>

### [`float CubicBezier3.Length(float precision)`](#api-fc1f63bec1873436)


```csharp
public float Length(float precision);
```

Approximates the arc length using adaptive subdivision until the error per segment is within `precision`.

<a id="api-27c950de1e47e0ed"></a>

### [`Point3 CubicBezier3.Lerp(float t)`](#api-27c950de1e47e0ed)


```csharp
public Point3 Lerp(float t);
```

Evaluates the curve at parameter `t` using De Casteljau&#39;s algorithm.

- **`t`** — A normalized parameter in the range [0, 1].

<a id="api-029ecde2e16bae7b"></a>

### [`Point3 CubicBezier3.P0`](#api-029ecde2e16bae7b)


```csharp
public readonly Point3 P0;
```

The starting point of the curve.

<a id="api-05bfe6f137ccd1e7"></a>

### [`Point3 CubicBezier3.P1`](#api-05bfe6f137ccd1e7)


```csharp
public readonly Point3 P1;
```

The first control point, influencing the curve near [`Xui.Core.Curves3D.CubicBezier3.P0`](../xui-core-curves3d/index.md#api-029ecde2e16bae7b).

<a id="api-85ef5f8bb37bf35b"></a>

### [`Point3 CubicBezier3.P2`](#api-85ef5f8bb37bf35b)


```csharp
public readonly Point3 P2;
```

The second control point, influencing the curve near [`Xui.Core.Curves3D.CubicBezier3.P3`](../xui-core-curves3d/index.md#api-f2677b9bb764d7ab).

<a id="api-f2677b9bb764d7ab"></a>

### [`Point3 CubicBezier3.P3`](#api-f2677b9bb764d7ab)


```csharp
public readonly Point3 P3;
```

The ending point of the curve.

<a id="api-9a6ccd56f9702411"></a>

### [`QuadraticBezier3 CubicBezier3.QuadraticApproximation`](#api-9a6ccd56f9702411)


```csharp
public QuadraticBezier3 QuadraticApproximation { get; }
```

Returns a quadratic B&#233;zier that approximates this cubic by averaging the endpoint tangents. Suitable as a fast approximation when subdivision is not required.

<a id="api-dc325984c2b0ba48"></a>

### [`(CubicBezier3 left, CubicBezier3 right) CubicBezier3.Subdivide(float t)`](#api-dc325984c2b0ba48)


```csharp
public (CubicBezier3 left, CubicBezier3 right) Subdivide(float t);
```

Subdivides this curve at parameter `t` using De Casteljau&#39;s algorithm, returning the left and right sub-curves.

- **`t`** — The split parameter in the range (0, 1).

<a id="api-c7d1355e2b118761"></a>

### [`Vector3 CubicBezier3.Tangent(float t)`](#api-c7d1355e2b118761)


```csharp
public Vector3 Tangent(float t);
```

Returns the tangent vector of the curve at parameter `t`.

- **`t`** — A normalized parameter in the range [0, 1].

<a id="api-9bef478ef4044195"></a>

### [`string CubicBezier3.ToString()`](#api-9bef478ef4044195)


```csharp
public override string ToString();
```

Returns the fully qualified type name of this instance.

**Returns:** The fully qualified type name.


<a id="api-e04ef643af8d70ef"></a>

## `interface ICurve3`

Defines a parametric curve in 3D space.

The parameter `t` ranges from 0 to 1, where 0 is the start and 1 is the end of the curve.

```csharp
public interface ICurve3
{
    Point3 Lerp(float t);
    Vector3 Tangent(float t);
    Point3 this[float t] { get; }

    float Length();
    float Length(float precision);
}
```

<a id="api-29fe9c07dace4e68"></a>

### [`Point3 ICurve3.this[float t]`](#api-29fe9c07dace4e68)


```csharp
Point3 this[float t] { get; }
```

Evaluates the curve at the given parameter `t`. Alias for [`Xui.Core.Curves3D.ICurve3.Lerp(System.Single)`](../xui-core-curves3d/index.md#api-7cf8ddd08adaf342).

<a id="api-a03969bc86ae3fde"></a>

### [`float ICurve3.Length()`](#api-a03969bc86ae3fde)


```csharp
float Length();
```

Approximates the arc length of the curve using 16 uniform samples.

<a id="api-f86c6d3de553029d"></a>

### [`float ICurve3.Length(float precision)`](#api-f86c6d3de553029d)


```csharp
float Length(float precision);
```

Approximates the arc length of the curve using adaptive subdivision until the error is within `precision`.

- **`precision`** — The maximum allowed error per segment.

<a id="api-7cf8ddd08adaf342"></a>

### [`Point3 ICurve3.Lerp(float t)`](#api-7cf8ddd08adaf342)


```csharp
Point3 Lerp(float t);
```

Evaluates the curve at the given parameter `t` and returns the corresponding point in 3D space.

- **`t`** — A normalized parameter in the range [0, 1].

<a id="api-0f9e0f04b71143a4"></a>

### [`Vector3 ICurve3.Tangent(float t)`](#api-0f9e0f04b71143a4)


```csharp
Vector3 Tangent(float t);
```

Returns the tangent (first derivative) vector of the curve at parameter `t`.

- **`t`** — A normalized parameter in the range [0, 1].


<a id="api-45d7d7129fdc3798"></a>

## `readonly struct LinearBezier3`

Represents a linear (degree-1) B&#233;zier curve in 3D space — a straight line segment from [`Xui.Core.Curves3D.LinearBezier3.P0`](../xui-core-curves3d/index.md#api-294bb250e0c66061) to [`Xui.Core.Curves3D.LinearBezier3.P1`](../xui-core-curves3d/index.md#api-1c9558c8fd771aa8).

```csharp
public readonly struct LinearBezier3 : ICurve3
{
    public readonly Point3 P0;
    public readonly Point3 P1;
    public LinearBezier3(Point3 p0, Point3 p1);
    public Point3 Lerp(float t);
    public Vector3 Tangent(float t);
    public Point3 this[float t] { get; }

    public float Length();
    public float Length(float precision);
    public QuadraticBezier3 ToQuadratic();
    public CubicBezier3 ToCubic();
    public override string ToString();
}
```

<a id="api-e56a104ac7dfd0a6"></a>

### [`LinearBezier3.LinearBezier3(Point3 p0, Point3 p1)`](#api-e56a104ac7dfd0a6)


```csharp
public LinearBezier3(Point3 p0, Point3 p1);
```

Initializes a new [`Xui.Core.Curves3D.LinearBezier3`](../xui-core-curves3d/index.md#api-45d7d7129fdc3798) with the specified endpoints.

<a id="api-4fbc1ecd5ed9e5d6"></a>

### [`Point3 LinearBezier3.this[float t]`](#api-4fbc1ecd5ed9e5d6)


```csharp
public Point3 this[float t] { get; }
```

Evaluates the curve at the given parameter `t`. Alias for [`Xui.Core.Curves3D.ICurve3.Lerp(System.Single)`](../xui-core-curves3d/index.md#api-7cf8ddd08adaf342).

<a id="api-412fe410661649e4"></a>

### [`float LinearBezier3.Length()`](#api-412fe410661649e4)


```csharp
public float Length();
```

Returns the length of the segment (the Euclidean distance from [`Xui.Core.Curves3D.LinearBezier3.P0`](../xui-core-curves3d/index.md#api-294bb250e0c66061) to [`Xui.Core.Curves3D.LinearBezier3.P1`](../xui-core-curves3d/index.md#api-1c9558c8fd771aa8)).

<a id="api-d195b87669b7ad73"></a>

### [`float LinearBezier3.Length(float precision)`](#api-d195b87669b7ad73)


```csharp
public float Length(float precision);
```

Returns the length of the segment. The `precision` parameter is ignored for linear segments.

<a id="api-9c3ce81402a350d2"></a>

### [`Point3 LinearBezier3.Lerp(float t)`](#api-9c3ce81402a350d2)


```csharp
public Point3 Lerp(float t);
```

Evaluates the segment at parameter `t`.

- **`t`** — A normalized parameter in the range [0, 1].

<a id="api-294bb250e0c66061"></a>

### [`Point3 LinearBezier3.P0`](#api-294bb250e0c66061)


```csharp
public readonly Point3 P0;
```

The starting point of the segment.

<a id="api-1c9558c8fd771aa8"></a>

### [`Point3 LinearBezier3.P1`](#api-1c9558c8fd771aa8)


```csharp
public readonly Point3 P1;
```

The ending point of the segment.

<a id="api-4ffda1243d643459"></a>

### [`Vector3 LinearBezier3.Tangent(float t)`](#api-4ffda1243d643459)


```csharp
public Vector3 Tangent(float t);
```

Returns the constant tangent (direction) of the segment.

- **`t`** — Ignored — the tangent is constant for a linear segment.

<a id="api-f6d7b78656e6e7fe"></a>

### [`CubicBezier3 LinearBezier3.ToCubic()`](#api-f6d7b78656e6e7fe)


```csharp
public CubicBezier3 ToCubic();
```

Converts this linear segment to a [`Xui.Core.Curves3D.CubicBezier3`](../xui-core-curves3d/index.md#api-bc7a3a4982dbbf11) with collinear controls.

<a id="api-456281fe165195ab"></a>

### [`QuadraticBezier3 LinearBezier3.ToQuadratic()`](#api-456281fe165195ab)


```csharp
public QuadraticBezier3 ToQuadratic();
```

Converts this linear segment to a [`Xui.Core.Curves3D.QuadraticBezier3`](../xui-core-curves3d/index.md#api-5cc9868b494141a7) with a midpoint control.

<a id="api-bea6bec213fe46bb"></a>

### [`string LinearBezier3.ToString()`](#api-bea6bec213fe46bb)


```csharp
public override string ToString();
```

Returns the fully qualified type name of this instance.

**Returns:** The fully qualified type name.


<a id="api-5cc9868b494141a7"></a>

## `readonly struct QuadraticBezier3`

Represents a quadratic (degree-2) B&#233;zier curve in 3D space, defined by a start point, one control point, and an end point.

A quadratic B&#233;zier provides smooth interpolation from [`Xui.Core.Curves3D.QuadraticBezier3.P0`](../xui-core-curves3d/index.md#api-ed10a0163a9d8e21) to [`Xui.Core.Curves3D.QuadraticBezier3.P2`](../xui-core-curves3d/index.md#api-b5bc4e384e82c509), pulled toward the control point [`Xui.Core.Curves3D.QuadraticBezier3.P1`](../xui-core-curves3d/index.md#api-fa514549581d75c0). Points are computed using De Casteljau&#39;s algorithm for numerical stability.

```csharp
public readonly struct QuadraticBezier3 : ICurve3
{
    public readonly Point3 P0;
    public readonly Point3 P1;
    public readonly Point3 P2;
    public QuadraticBezier3(Point3 p0, Point3 p1, Point3 p2);
    public Point3 Lerp(float t);
    public Vector3 Tangent(float t);
    public Point3 this[float t] { get; }

    public float Length();
    public float Length(float precision);
    public (QuadraticBezier3 left, QuadraticBezier3 right) Subdivide(float t);
    public CubicBezier3 ToCubic();
    public override string ToString();
}
```

<a id="api-e5d1d1ff551e6eb1"></a>

### [`QuadraticBezier3.QuadraticBezier3(Point3 p0, Point3 p1, Point3 p2)`](#api-e5d1d1ff551e6eb1)


```csharp
public QuadraticBezier3(Point3 p0, Point3 p1, Point3 p2);
```

Initializes a new [`Xui.Core.Curves3D.QuadraticBezier3`](../xui-core-curves3d/index.md#api-5cc9868b494141a7) with the specified control points.

<a id="api-694d15100a1a4647"></a>

### [`Point3 QuadraticBezier3.this[float t]`](#api-694d15100a1a4647)


```csharp
public Point3 this[float t] { get; }
```

Evaluates the curve at the given parameter `t`. Alias for [`Xui.Core.Curves3D.ICurve3.Lerp(System.Single)`](../xui-core-curves3d/index.md#api-7cf8ddd08adaf342).

<a id="api-45ec721815617a3c"></a>

### [`float QuadraticBezier3.Length()`](#api-45ec721815617a3c)


```csharp
public float Length();
```

Approximates the arc length using 16 uniform samples.

<a id="api-7f9860142290bc8d"></a>

### [`float QuadraticBezier3.Length(float precision)`](#api-7f9860142290bc8d)


```csharp
public float Length(float precision);
```

Approximates the arc length using adaptive subdivision until the error per segment is within `precision`.

<a id="api-215b31f9ccaf00b9"></a>

### [`Point3 QuadraticBezier3.Lerp(float t)`](#api-215b31f9ccaf00b9)


```csharp
public Point3 Lerp(float t);
```

Evaluates the curve at parameter `t` using De Casteljau&#39;s algorithm.

- **`t`** — A normalized parameter in the range [0, 1].

<a id="api-ed10a0163a9d8e21"></a>

### [`Point3 QuadraticBezier3.P0`](#api-ed10a0163a9d8e21)


```csharp
public readonly Point3 P0;
```

The starting point of the curve.

<a id="api-fa514549581d75c0"></a>

### [`Point3 QuadraticBezier3.P1`](#api-fa514549581d75c0)


```csharp
public readonly Point3 P1;
```

The control point, which influences the curvature.

<a id="api-b5bc4e384e82c509"></a>

### [`Point3 QuadraticBezier3.P2`](#api-b5bc4e384e82c509)


```csharp
public readonly Point3 P2;
```

The ending point of the curve.

<a id="api-a9c1e708398a4885"></a>

### [`(QuadraticBezier3 left, QuadraticBezier3 right) QuadraticBezier3.Subdivide(float t)`](#api-a9c1e708398a4885)


```csharp
public (QuadraticBezier3 left, QuadraticBezier3 right) Subdivide(float t);
```

Subdivides this curve at parameter `t` using De Casteljau&#39;s algorithm, returning the left and right sub-curves.

- **`t`** — The split parameter in the range (0, 1).

<a id="api-b5cd483bfe364c4c"></a>

### [`Vector3 QuadraticBezier3.Tangent(float t)`](#api-b5cd483bfe364c4c)


```csharp
public Vector3 Tangent(float t);
```

Returns the tangent vector of the curve at parameter `t`.

- **`t`** — A normalized parameter in the range [0, 1].

<a id="api-f662c8ab7aac7a49"></a>

### [`CubicBezier3 QuadraticBezier3.ToCubic()`](#api-f662c8ab7aac7a49)


```csharp
public CubicBezier3 ToCubic();
```

Elevates this quadratic curve to an equivalent [`Xui.Core.Curves3D.CubicBezier3`](../xui-core-curves3d/index.md#api-bc7a3a4982dbbf11).

<a id="api-49e008c767db98c2"></a>

### [`string QuadraticBezier3.ToString()`](#api-49e008c767db98c2)


```csharp
public override string ToString();
```

Returns the fully qualified type name of this instance.

**Returns:** The fully qualified type name.

