11import { linspace , sgn , infinity , clamp , space , isValidNumber } from '../utils.mjs'
2- import { builtIn as evaluate } from './eval.mjs'
2+ import { builtIn as builtInEvaluate , interval as intervalEvaluate } from './eval.mjs'
33
44import type { FunctionPlotDatum , FunctionPlotScale , PointFunction , VectorFunction } from '../types.js'
55import type { SamplerParams , SamplerFn , BuiltInSamplerResult , BuiltInSamplerResultGroup } from './types.js'
@@ -27,7 +27,7 @@ function checkAsymptote(
2727 let oldY : number , oldX : number
2828 for ( let i = 0 ; i < n ; i += 1 ) {
2929 const x = samples [ i ]
30- const y = evaluate ( d , 'fn' , { x } )
30+ const y = builtInEvaluate ( d , 'fn' , { x } )
3131
3232 if ( oldY ) {
3333 const deltaY = y - oldY
@@ -120,13 +120,15 @@ function linear(samplerParams: SamplerParams): BuiltInSamplerResult {
120120 const yMin = yDomain [ 0 ] - infinity ( )
121121 const yMax = yDomain [ 1 ] + infinity ( )
122122 const data : Array < [ number , number ] > = [ ]
123+ let oldY : number
123124 for ( let i = 0 ; i < allX . length ; i += 1 ) {
124125 const x = allX [ i ]
125- let y = evaluate ( samplerParams . d , 'fn' , { x } )
126+ let y = builtInEvaluate ( samplerParams . d , 'fn' , { x } )
126127 if ( isValidNumber ( x ) && isValidNumber ( y ) ) {
127128 y = clamp ( y , yMin , yMax )
128129 data . push ( [ x , y ] )
129130 }
131+ oldY = y
130132 }
131133 const splitData = split ( samplerParams . d , data , samplerParams . yScale )
132134 return splitData
@@ -140,8 +142,8 @@ function parametric(samplerParams: SamplerParams): BuiltInSamplerResult {
140142 const samples : BuiltInSamplerResultGroup = [ ]
141143 for ( let i = 0 ; i < tCoords . length ; i += 1 ) {
142144 const t = tCoords [ i ]
143- const x = evaluate ( samplerParams . d , 'x' , { t } )
144- const y = evaluate ( samplerParams . d , 'y' , { t } )
145+ const x = builtInEvaluate ( samplerParams . d , 'x' , { t } )
146+ const y = builtInEvaluate ( samplerParams . d , 'y' , { t } )
145147 samples . push ( [ x , y ] )
146148 }
147149 return [ samples ]
@@ -155,7 +157,7 @@ function polar(samplerParams: SamplerParams): BuiltInSamplerResult {
155157 const samples : BuiltInSamplerResultGroup = [ ]
156158 for ( let i = 0 ; i < thetaSamples . length ; i += 1 ) {
157159 const theta = thetaSamples [ i ]
158- const r = evaluate ( samplerParams . d , 'r' , { theta } )
160+ const r = builtInEvaluate ( samplerParams . d , 'r' , { theta } )
159161 const x = r * Math . cos ( theta )
160162 const y = r * Math . sin ( theta )
161163 samples . push ( [ x , y ] )
0 commit comments