From baab2e70cfb537e4bb1fe7c4a3373057b3a988ee Mon Sep 17 00:00:00 2001 From: pixelzoom Date: Thu, 23 Mar 2023 11:45:40 -0400 Subject: [PATCH] convert deltaX from a getter to a field, https://github.com/phetsims/calculus-grapher/issues/311 --- js/common/model/Curve.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/js/common/model/Curve.ts b/js/common/model/Curve.ts index 41817f10..ab1e2249 100644 --- a/js/common/model/Curve.ts +++ b/js/common/model/Curve.ts @@ -70,6 +70,9 @@ export default class Curve extends PhetioObject { // Number of points (evenly-spaced along the x-axis) that will be used to approximate the curve public readonly numberOfPoints: number; + // Delta between x coordinate values + protected readonly deltaX: number; + protected constructor( providedOptions: CurveOptions ) { const options = optionize()( { @@ -85,9 +88,9 @@ export default class Curve extends PhetioObject { super( options ); - // create a reference to these option fields this.xRange = options.xRange; this.numberOfPoints = options.numberOfPoints; + this.deltaX = this.xRange.getLength() / ( this.numberOfPoints - 1 ); // Initial points, with equally-spaced x values, and y=0. // These CurvePoint instances are reused throughout the lifetime of the sim, and never disposed. @@ -171,10 +174,6 @@ export default class Curve extends PhetioObject { return Utils.roundSymmetric( normalizedValue * ( this.numberOfPoints - 1 ) ); } - protected get deltaX(): number { - return this.xRange.getLength() / ( this.numberOfPoints - 1 ); - } - /** * Gets the index of the array whose x-value is closest to the given x-value. */