UnitBezier

UnitBezier

Calculates the Y coordinate for a given X coordinate on a Bezier curve.

Constructor

new UnitBezier(points, epsilon)

Creates a new UnitBezier Object

Parameters:
Name Type Description
points Array.<Number>

The control points of a Bezier curve [x1, y1, x2, y2].

epsilon Number

An epsilon to determine the acceptable error for the answer.

Source:

Namespaces

easings

Methods

(private) binarySubdivide(x, tBoundsLow, tBoundsHigh) → {Number}

Parameters:
Name Type Description
x Number

Desired coordinate 0 <= x <= 1

tBoundsLow Number

Lowest possible percentage where x could appear.

tBoundsHigh Number

Highest possible percentage where x could appear.

Source:
Returns:

Percentage through curve.

Type
Number

calc(timePercent) → {Number}

Calculates the Y coordinate for a given X coordinate on a Bezier curve.

Parameters:
Name Type Description
timePercent Number

The x coordinate (time through animation).

Source:
Returns:

The y coordinate (interpolation factor).

Type
Number

(private) esitimateT(x) → {Number}

Estimates the percentage through the curve that a given x coordinate appears on the curve with a look up table.

Parameters:
Name Type Description
x Number

Desired coordinate 0 <= x <= 1

Source:
Returns:

Estimated percentage through curve.

Type
Number

(private) generateSampleTable() → {Array.<Number>}

Generates a look up table to speed up calculations.

Source:
Returns:

Look up table.

Type
Array.<Number>

(private) newtonRaphsonIterate(x, estimatedT) → {Number}

Parameters:
Name Type Description
x Number

Desired coordinate 0 <= x <= 1

estimatedT Number

Initial estimate of percentage through curve.

Source:
Returns:

Percentage through curve or -1 for a failure.

Type
Number

(private) sampleCurveDerivativeX(t) → {Number}

Gets the derivative of the Bezier curve at a given percentage through the curve.

Parameters:
Name Type Description
t Number

Percentage through the curve 0 <= t <= 1

Source:
Returns:

Derivative of curve.

Type
Number

(private) sampleCurveX(t) → {Number}

Gets the x coordinate of the Bezier curve at a given percentage through the curve.

Parameters:
Name Type Description
t Number

Percentage through the curve 0 <= t <= 1

Source:
Returns:

x coordinate of curve.

Type
Number

(private) sampleCurveY(t) → {Number}

Gets the y coordinate of the Bezier curve at a given percentage through the curve.

Parameters:
Name Type Description
t Number

Percentage through the curve 0 <= t <= 1

Source:
Returns:

y coordinate of curve.

Type
Number

(private) solveCurveX(x) → {Number}

Gets the percentage through the curve that a given x coordinate appears on the curve.

Parameters:
Name Type Description
x Number

Desired coordinate 0 <= x <= 1

Source:
Returns:

Percentage through curve.

Type
Number