BezierType

public protocol BezierType

Protocol for Bézier curve types, with outputs that are geometric in nature.

  • The type for the input of this Bézier curve type.

    Declaration

    Swift

    associatedtype Input : FloatingPoint
  • The type for the output of this Bézier curve type.

    Declaration

    Swift

    associatedtype Output : BezierPointType
  • startInput Default implementation

    The minimal input that can be computed in this Bézier curve.

    Default Implementation

    Declaration

    Swift

    var startInput: Input { get }
  • endInput Default implementation

    The maximal input that can be computed in this Bézier curve.

    Default Implementation

    Declaration

    Swift

    var endInput: Input { get }
  • The number of points on this Bézier curve. Should always be >= 1 for any degree of Bézier curve object greater than -1.

    Declaration

    Swift

    var pointCount: Int { get }
  • Returns the point at a specified point index.

    Precondition

    pointIndex >= 0 && pointIndex < pointCount.

    Declaration

    Swift

    subscript(pointIndex: Int) -> Output { get }
  • points Default implementation

    Gets a list of all control points for this Bézier curve. Always contains at least one point for any degree of Bézier curve object greater than -1.

    Default Implementation

    Declaration

    Swift

    var points: [Output] { get }
  • firstPoint Default implementation

    Gets the first control point of this Bézier curve object. It is necessarily the same as the point obtained by compute(at: startInput).

    Default Implementation

    Declaration

    Swift

    var firstPoint: Output { get }
  • lastPoint Default implementation

    Gets the last control point of this Bézier curve object. It is necessarily the same as the point obtained by compute(at: endInput).

    Default Implementation

    Declaration

    Swift

    var lastPoint: Output { get }
  • Requests that a new output value be computed at a specified input using the fastest implementation mode available for this type.

    Declaration

    Swift

    func compute(at input: Input) -> Output
  • computeSeries(steps:) Default implementation

    Requests that a series of output values be computed for this Bézier, with intervals that divide startInput and endInput into steps number of equally-spaced input values.

    Returned array always contains the result of startInput and endInput themselves, which are the first and last points on this Bézier curve, so those two points don’t count towards the number of steps.

    Precondition

    steps >= 0.

    Default Implementation

    Declaration

    Swift

    func computeSeries(steps: Int) -> [Output]
  • createLookupTable(steps:) Default implementation

    Creates a lookup table for this Bézier curve with a given number of subdivision steps within it.

    Returned lookup table always contains the result of startInput and endInput themselves, which are the first and last points on this Bézier curve, so those two points don’t count towards the number of steps.

    Precondition

    steps >= 0.

    Default Implementation

    Declaration

    Swift

    func createLookupTable(steps: Int) -> BezierLookUpTable<Self>
  • Performs an approximation of the closest point on this Bézier to a given point outside of it.

    The approximation is controlled by a number of steps to split the Bézier into before the closest interval is found and iterating over it until it either exceeds a number of maximum iterations or the point approaches a limit where changes to input are smaller than tolerance.

    Default Implementation

    Declaration

    Swift

    func projectApproximate(
        to point: Output,
        steps: Int,
        maxIterations: Int,
        tolerance: Output.Scalar
    ) -> (t: Input, output: Output)
  • Performs an approximation of a given function on this Bézier towards zero.

    The approximation is controlled by a number of steps to split the Bézier into before the closest interval to zero is found and iterating over it until it either exceeds a number of maximum iterations or the function approaches a limit where changes to input are smaller than tolerance.

    Expects producer to be a contiguous function mapping Input into Output.Scalar.

    May produce multiple approximations depending on the degree of this Bézier curve.

    Default Implementation

    Declaration

    Swift

    func approximate(
        _ producer: (Output) -> Output.Scalar,
        steps: Int,
        maxIterations: Int,
        tolerance: Output.Scalar
    ) -> [(t: Input, output: Output)]
  • Returns the result of translating the points of this Bézier curve by offset.

    Declaration

    Swift

    func translated(by offset: Output) -> Self