@revideo/2d / curves / Polynomial
Class: Polynomial
Defined in: 2d/src/lib/curves/Polynomial.ts:9
A polynomial in the form ax^3 + bx^2 + cx + d up to a cubic polynomial.
Source code liberally taken from: https://github.com/FreyaHolmer/Mathfs/blob/master/Runtime/Curves/Polynomial.cs
Constructors
Constructor
new Polynomial(
c0):Polynomial
Defined in: 2d/src/lib/curves/Polynomial.ts:78
Parameters
c0
number
The constant coefficient
Returns
Polynomial
Constructor
new Polynomial(
c0,c1):Polynomial
Defined in: 2d/src/lib/curves/Polynomial.ts:83
Parameters
c0
number
The constant coefficient
c1
number
The linear coefficient
Returns
Polynomial
Constructor
new Polynomial(
c0,c1,c2):Polynomial
Defined in: 2d/src/lib/curves/Polynomial.ts:89
Parameters
c0
number
The constant coefficient
c1
number
The linear coefficient
c2
number
The quadratic coefficient
Returns
Polynomial
Constructor
new Polynomial(
c0,c1,c2,c3):Polynomial
Defined in: 2d/src/lib/curves/Polynomial.ts:96
Parameters
c0
number
The constant coefficient
c1
number
The linear coefficient
c2
number
The quadratic coefficient
c3
number
The cubic coefficient
Returns
Polynomial
Properties
c0
readonlyc0:number
Defined in: 2d/src/lib/curves/Polynomial.ts:98
c1
readonlyc1:number
Defined in: 2d/src/lib/curves/Polynomial.ts:10
c2
readonlyc2:number
Defined in: 2d/src/lib/curves/Polynomial.ts:11
c3
readonlyc3:number
Defined in: 2d/src/lib/curves/Polynomial.ts:12
Accessors
degree
Get Signature
get degree():
number
Defined in: 2d/src/lib/curves/Polynomial.ts:64
The degree of the polynomial
Returns
number
Methods
differentiate()
differentiate(
n?):Polynomial
Defined in: 2d/src/lib/curves/Polynomial.ts:113
Return the nth derivative of the polynomial.
Parameters
n?
number = 1
The number of times to differentiate the polynomial.
Returns
Polynomial
eval()
Call Signature
eval(
t):number
Defined in: 2d/src/lib/curves/Polynomial.ts:133
Evaluate the polynomial at the given value t.
Parameters
t
number
The value to sample at
Returns
number
Call Signature
eval(
t,derivative):number
Defined in: 2d/src/lib/curves/Polynomial.ts:140
Evaluate the nth derivative of the polynomial at the given value t.
Parameters
t
number
The value to sample at
derivative
number
The derivative of the polynomial to sample from
Returns
number
localExtrema()
localExtrema():
number[]
Defined in: 2d/src/lib/curves/Polynomial.ts:196
Calculate the local extrema of the polynomial.
Returns
number[]
localExtrema01()
localExtrema01():
number[]
Defined in: 2d/src/lib/curves/Polynomial.ts:203
Calculate the local extrema of the polynomial in the unit interval.
Returns
number[]
outputRange01()
outputRange01():
number[]
Defined in: 2d/src/lib/curves/Polynomial.ts:218
Return the output value range within the unit interval.
Returns
number[]
roots()
roots():
number[]
Defined in: 2d/src/lib/curves/Polynomial.ts:178
Calculate the roots (values where this polynomial = 0).
Returns
number[]
Remarks
Depending on the degree of the polynomial, returns between 0 and 3 results.
split()
split(
u): [Polynomial,Polynomial]
Defined in: 2d/src/lib/curves/Polynomial.ts:153
Split the polynomial into two polynomials of the same overall shape.
Parameters
u
number
The point at which to split the polynomial.
Returns
[Polynomial, Polynomial]
constant()
staticconstant(c0):Polynomial
Defined in: 2d/src/lib/curves/Polynomial.ts:19
Constructs a constant polynomial
Parameters
c0
number
The constant coefficient
Returns
Polynomial
cubic()
staticcubic(c0,c1,c2,c3):Polynomial
Defined in: 2d/src/lib/curves/Polynomial.ts:52
Constructs a cubic polynomial
Parameters
c0
number
The constant coefficient
c1
number
The linear coefficient
c2
number
The quadratic coefficient
c3
number
The cubic coefficient
Returns
Polynomial
linear()
staticlinear(c0,c1):Polynomial
Defined in: 2d/src/lib/curves/Polynomial.ts:29
Constructs a linear polynomial
Parameters
c0
number
The constant coefficient
c1
number
The linear coefficient
Returns
Polynomial
quadratic()
staticquadratic(c0,c1,c2):Polynomial
Defined in: 2d/src/lib/curves/Polynomial.ts:40
Constructs a quadratic polynomial
Parameters
c0
number
The constant coefficient
c1
number
The linear coefficient
c2
number
The quadratic coefficient
Returns
Polynomial