From 14f0d5e46ceb04102bacfcd8c1519877237f3aa2 Mon Sep 17 00:00:00 2001 From: zepumph Date: Tue, 19 Feb 2019 13:30:36 -0900 Subject: [PATCH] add farthest and closest qualitative distance strings, see https://github.com/phetsims/gravity-force-lab-basics/issues/88 --- .../view/describers/GFLBPositionDescriber.js | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/js/gravity-force-lab-basics/view/describers/GFLBPositionDescriber.js b/js/gravity-force-lab-basics/view/describers/GFLBPositionDescriber.js index 82dfe57..7f27b62 100644 --- a/js/gravity-force-lab-basics/view/describers/GFLBPositionDescriber.js +++ b/js/gravity-force-lab-basics/view/describers/GFLBPositionDescriber.js @@ -37,8 +37,7 @@ define( require => { } getOnlyQualitativeObjectDistanceSummary() { - const pattern = mass1Mass2QualitativeDistancePatternString; - return StringUtils.fillIn( pattern, { + return StringUtils.fillIn( mass1Mass2QualitativeDistancePatternString, { mass1: this.object1Label, mass2: this.object2Label, qualitativeDistance: this.qualitativeDistance @@ -49,6 +48,41 @@ define( require => { return StringUtils.fillIn( massesDistanceApartPatternString, { distance: distance } ); } + // @override + getDistanceIndex( distance ) { + assert && assert( distance > 0, 'Distance between spheres should always be positive.' ); + + console.log( distance ); + if ( distance === 9.6 ) { + return 0; + } + if ( distance >= 9.0 ) { + return 1; + } + if ( distance >= 7.6 ) { + return 2; + } + if ( distance >= 6.1 ) { + return 3; + } + if ( distance >= 4.6 ) { + return 4; + } + if ( distance >= 3.1 ) { + return 5; + } + if ( distance >= 2.0 ) { + return 6; + } + if ( distance >= 1.4 ) { + return 7; + } + if ( distance === 1.3 ) { + return 8; + } + assert && assert( false, 'Invalid distance value' ); + } + /** * Uses the singleton pattern to keep one instance of this describer for the entire lifetime of the sim. * @returns {GFLBPositionDescriber}