phetsims / faradays-electromagnetic-lab

"Faraday's Electromagnetic Lab" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
1 stars 0 forks source link

Field meter is not displaying small non-zero gauss values correctly. #154

Closed pixelzoom closed 3 months ago

pixelzoom commented 3 months ago

Specifically it's not doing the correct thing for negative small non-zero gauss values. Here's the offending code in FieldMeterNode, where this gets skipped if gauss is negative:

  if ( gauss > 0 && gauss < GAUSS_MIN_DISPLAY_VALUE ) {

    // Display '< 0.01' instead of '0.00' for small non-zero values, see https://github.com/phetsims/faradays-electromagnetic-lab/issues/84
    return StringUtils.fillIn( lessThanValueUnits, {
      value: `${GAUSS_MIN_DISPLAY_VALUE}`,
      units: G
    } );
  }

Fixing this is straightforward, by using Math.abs( gauss ).

But then there's a new problem -- what should be displayed if (for example) gauss is -0.001? Displaying "< 0.01" does not seem correct, because it implies a positive value.

Note that this is a problem for Bx and By, which are signed. B (magnitude) is unsigned.

pixelzoom commented 3 months ago

@arouinfar Thoughts on what to display for small negative values?

arouinfar commented 3 months ago

@pixelzoom instead of displaying "< 0.01" we could display "~ 0.00" for any value with an absolute value < 0.01. We do this in Collision Lab for small, non-zero values. When using the about "~" notation, the sign becomes irrelevant. image

pixelzoom commented 3 months ago

I asked a today's dev meeting, and developer's felt that the "~" notation was appropriate here.

For my first attempt, "~0.00" looks too much like a negative sign:

screenshot_3154

Adding a space looks like it would be less likely to be confused with a negative sign, but I don't know how "~" is typically used:

screenshot_3153

@arouinfar Let's discuss.

pixelzoom commented 3 months ago

Discussed with @arouinfar.

We'll go with "~ 0 G" for B, Bx, By -- see screenshot below.

We decided NOT to do the same for theta.

screenshot_3159
pixelzoom commented 3 months ago

Test drive in main or 1.0.0-dev.20.

Over to @arouinfar for review, close if OK.

arouinfar commented 3 months ago

Looks good, thanks @pixelzoom! Closing.