Skip to content

PiecewiseLinearFunction

Overview

Evaluates points on a piecewise linear function.

@author Sam Reid (PhET Interactive Simulations)

Class PiecewiseLinearFunction

import { PiecewiseLinearFunction } from 'scenerystack/dot';

Constructor

new PiecewiseLinearFunction( array : number[] )

Instance Methods

evaluate( x : number ) : number

Static Methods

evaluate( array : number[], x : number ) : number

This algorithm generates no garbage @param array - in the form x0,y0, x1,y1, x2,y2, etc. Points do not have to be ordered from low to high x - points cannot have a different y value for the same x value (not checked) @param x

Source Code

See the source for PiecewiseLinearFunction.ts in the dot repository.