docs.unity3d.com
    Show / Hide Table of Contents

    Class CurveUtility

    A collection of methods for extracting information about BezierCurve types.

    Inheritance
    Object
    CurveUtility
    Namespace: UnityEngine.Splines
    Syntax
    public static class CurveUtility

    Methods

    ApproximateLength(BezierCurve)

    Calculate the approximate length of a BezierCurve. This is less accurate than CalculateLength(BezierCurve), but can be significantly faster. Use this when accuracy is not paramount and the curve control points are changing frequently.

    Declaration
    public static float ApproximateLength(BezierCurve curve)
    Parameters
    Type Name Description
    BezierCurve curve

    The BezierCurve to calculate length.

    Returns
    Type Description
    Single

    An estimate of the length of a curve.

    CalculateLength(BezierCurve)

    Calculate the length of a BezierCurve by unrolling the curve into linear segments and summing the lengths of the lines. This is equivalent to accessing GetCurveLength(Int32).

    Declaration
    public static float CalculateLength(BezierCurve curve)
    Parameters
    Type Name Description
    BezierCurve curve

    The BezierCurve to calculate length.

    Returns
    Type Description
    Single

    The sum length of a collection of linear segments fitting this curve.

    See Also
    ApproximateLength(BezierCurve)

    EvaluatePosition(BezierCurve, Single)

    Given a bezier curve, return an interpolated position at ratio t.

    Declaration
    public static float3 EvaluatePosition(BezierCurve curve, float t)
    Parameters
    Type Name Description
    BezierCurve curve

    A cubic bezier curve.

    Single t

    A value between 0 and 1 representing the ratio along the curve.

    Returns
    Type Description
    float3

    A position on the curve.

    EvaluateTangent(BezierCurve, Single)

    Given a bezier curve, return an interpolated tangent at ratio t.

    Declaration
    public static float3 EvaluateTangent(BezierCurve curve, float t)
    Parameters
    Type Name Description
    BezierCurve curve

    A cubic bezier curve.

    Single t

    A value between 0 and 1 representing the ratio along the curve.

    Returns
    Type Description
    float3

    A tangent on the curve.

    Split(BezierCurve, Single, out BezierCurve, out BezierCurve)

    Decompose a curve into two smaller curves matching the source curve.

    Declaration
    public static void Split(BezierCurve curve, float t, out BezierCurve left, out BezierCurve right)
    Parameters
    Type Name Description
    BezierCurve curve

    The source curve.

    Single t

    A mid-point on the source curve defining where the two smaller curves control points meet.

    BezierCurve left

    A curve from the source curve first control point to the mid-point, matching the curvature of the source curve.

    BezierCurve right

    A curve from the mid-point to the source curve fourth control point, matching the curvature of the source curve.

    In This Article
    • Methods
      • ApproximateLength(BezierCurve)
      • CalculateLength(BezierCurve)
      • EvaluatePosition(BezierCurve, Single)
      • EvaluateTangent(BezierCurve, Single)
      • Split(BezierCurve, Single, out BezierCurve, out BezierCurve)
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023