# modeling/curves/bezier

Represents a bezier easing function.

Source:
See:
• bezier for data structure information.

### Methods

#### (static) create(points) → {bezier}

Source:

Creates an object representing a bezier easing curve. Curves can have both an arbitrary number of control points, and an arbitrary number of dimensions.

##### Example
``````const b = bezier.create([0,10]) // a linear progression from 0 to 10
const b = bezier.create([0, 0, 10, 10]) // a symmetrical cubic easing curve that starts slowly and ends slowly from 0 to 10
const b = bezier.create([0,0,0], [0,5,10], [10,0,-5], [10,10,10]]) // a cubic 3 dimensional easing curve that can generate position arrays for modelling
// Usage
let position = bezier.valueAt(t,b) // where 0 < t < 1
let tangent = bezier.tangentAt(t,b) // where 0 < t < 1``````
##### Parameters:
Name Type Description
`points` Array

An array with at least 2 elements of either all numbers, or all arrays of numbers that are the same size.

##### Returns:

a new bezier data object

Type
bezier

#### (static) tangentAt(t, bezier) → {array|number}

Source:

Calculates the tangent at a specific position along a bezier easing curve. For multidimensional curves, the tangent is the slope of each dimension at that point. See the example called extrudeAlongPath.js

##### Example
``````const b = bezier.create([[0,0,0], [0,5,10], [10,0,-5], [10,10,10]]) // a cubic 3 dimensional easing curve that can generate position arrays for modelling
let tangent = bezier.tangentAt(t, b)``````
##### Parameters:
Name Type Description
`t` number

: the position of which to calculate the bezier's tangent value; 0 < t < 1

`bezier` Object

: an array with at least 2 elements of either all numbers, or all arrays of numbers that are the same size.

##### Returns:

the tangent at the requested position.

Type
array | number

#### (static) valueAt(t, bezier) → {array|number}

Source:

Calculates the value at a specific position along a bezier easing curve. For multidimensional curves, the tangent is the slope of each dimension at that point. See the example called extrudeAlongPath.js to see this in use. Math and explanation comes from https://www.freecodecamp.org/news/nerding-out-with-bezier-curves-6e3c0bc48e2f/

##### Example
``````const b = bezier.create([0,0,0], [0,5,10], [10,0,-5], [10,10,10]]) // a cubic 3 dimensional easing curve that can generate position arrays for modelling
let position = bezier.valueAt(t,b) // where 0 < t < 1``````
##### Parameters:
Name Type Description
`t` number

: the position of which to calculate the value; 0 < t < 1

`bezier` Object

: a bezier curve created with bezier.create().

##### Returns:

the value at the requested position.

Type
array | number