Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/external.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ declare module 'interval-arithmetic-eval' {
export class Interval {
lo: number
hi: number

constructor(lo: number | Interval, hi?: number)
static isEmpty(n: Interval | number): boolean
static isWhole(n: Interval | number): boolean
static intervalsOverlap(n: Interval, r: Interval): boolean
Expand Down
12 changes: 6 additions & 6 deletions src/samplers/builtIn.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { linspace, sgn, infinity, clamp, space, isValidNumber } from '../utils.mjs'
import { builtIn as evaluate } from './eval.mjs'
import { builtIn as builtInEvaluate } from './eval.mjs'

import type { FunctionPlotDatum, FunctionPlotScale, PointFunction, VectorFunction } from '../types.js'
import type { SamplerParams, SamplerFn, BuiltInSamplerResult, BuiltInSamplerResultGroup } from './types.js'
Expand Down Expand Up @@ -27,7 +27,7 @@ function checkAsymptote(
let oldY: number, oldX: number
for (let i = 0; i < n; i += 1) {
const x = samples[i]
const y = evaluate(d, 'fn', { x })
const y = builtInEvaluate(d, 'fn', { x })

if (oldY) {
const deltaY = y - oldY
Expand Down Expand Up @@ -122,7 +122,7 @@ function linear(samplerParams: SamplerParams): BuiltInSamplerResult {
const data: Array<[number, number]> = []
for (let i = 0; i < allX.length; i += 1) {
const x = allX[i]
let y = evaluate(samplerParams.d, 'fn', { x })
let y = builtInEvaluate(samplerParams.d, 'fn', { x })
if (isValidNumber(x) && isValidNumber(y)) {
y = clamp(y, yMin, yMax)
data.push([x, y])
Expand All @@ -140,8 +140,8 @@ function parametric(samplerParams: SamplerParams): BuiltInSamplerResult {
const samples: BuiltInSamplerResultGroup = []
for (let i = 0; i < tCoords.length; i += 1) {
const t = tCoords[i]
const x = evaluate(samplerParams.d, 'x', { t })
const y = evaluate(samplerParams.d, 'y', { t })
const x = builtInEvaluate(samplerParams.d, 'x', { t })
const y = builtInEvaluate(samplerParams.d, 'y', { t })
samples.push([x, y])
}
return [samples]
Expand All @@ -155,7 +155,7 @@ function polar(samplerParams: SamplerParams): BuiltInSamplerResult {
const samples: BuiltInSamplerResultGroup = []
for (let i = 0; i < thetaSamples.length; i += 1) {
const theta = thetaSamples[i]
const r = evaluate(samplerParams.d, 'r', { theta })
const r = builtInEvaluate(samplerParams.d, 'r', { theta })
const x = r * Math.cos(theta)
const y = r * Math.sin(theta)
samples.push([x, y])
Expand Down
6 changes: 3 additions & 3 deletions src/samplers/interval.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import intervalArithmeticEval, { Interval } from 'interval-arithmetic-eval'

import { interval as evaluate } from './eval.mjs'
import { interval as intervalEvaluate, builtIn as builtInEvaluate } from './eval.mjs'
import { infinity, space, interval2dTypedArray } from '../utils.mjs'
import globals from '../globals.mjs'

Expand Down Expand Up @@ -125,7 +125,7 @@ function interval1d({ d, xAxis, range, nSamples, xScale, yScale }: SamplerParams
const samples: IntervalSamplerResultGroup = []
for (let i = 0; i < xCoords.length - 1; i += 1) {
const x = { lo: xCoords[i], hi: xCoords[i + 1] }
const y = evaluate(d, 'fn', { x })
const y = intervalEvaluate(d, 'fn', { x })
if (!Interval.isEmpty(y) && !Interval.isWhole(y)) {
samples.push([x, y])
}
Expand Down Expand Up @@ -179,7 +179,7 @@ function smallRect(x: Interval, _: Interval) {
}

function quadTree(x: Interval, y: Interval, d: FunctionPlotDatum) {
const sample = evaluate(d, 'fn', { x, y })
const sample = intervalEvaluate(d, 'fn', { x, y })
const fulfills = Interval.zeroIn(sample)
if (!fulfills) {
return this
Expand Down