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 implementationThe minimal input that can be computed in this Bézier curve.
Default Implementation
Declaration
Swift
var startInput: Input { get }
-
endInput
Default implementationThe 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 implementationGets 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 implementationGets 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 implementationGets 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 }
-
computeSeries(steps:
Default implementation) Requests that a series of output values be computed for this Bézier, with intervals that divide
startInput
andendInput
intosteps
number of equally-spaced input values.Returned array always contains the result of
startInput
andendInput
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
andendInput
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>
-
projectApproximate(to:
Default implementationsteps: maxIterations: tolerance: ) 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
-
approximate(_:
Default implementationsteps: maxIterations: tolerance: ) 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 mappingInput
intoOutput.Scalar
.May produce multiple approximations depending on the degree of this Bézier curve.
Default Implementation
-
Returns the result of translating the points of this Bézier curve by
offset
.Declaration
Swift
func translated(by offset: Output) -> Self