phetsims / calculus-grapher

"Calculus Grapher" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
4 stars 4 forks source link

Reference Line's x value should snap to 1 decimal place #305

Closed pixelzoom closed 1 year ago

pixelzoom commented 1 year ago

For https://github.com/phetsims/qa/issues/921 ...

While working on other issues, I noticed that with "Value" preference on, the Reference Line displays only 1 decimal place for the x value. For example:

screenshot_2462

But inspecting tools.referenceLine.xProperty in Studio, the value is actually 5.496479633520075.

So much like sliders, I believe that we should be snapping to 1 decimal place at the end of a drag cycle. I'm going to go ahead and do this, and confirm later during review.

Other scrubbers (tangent, area) do not need to be snapped, because they do not display the x coordinate.

pixelzoom commented 1 year ago

Ready for review by @amanda-phet. First, confirm that this change is desired. Then confirm that it is working correctly: Open the sim in Studio, select tools.referenceLine.xProperty in the tree, then drag the Reference Line scrubber. Confirm that the xProperty snaps to 1 decimal place when the Reference Line scrubber is released.

veillette commented 1 year ago

@amanda-phet stated in a Slack conversation:

Yes, I agree the change is a good one (the lack of precision's of the line actually came up in a meeting I was in Friday!) ... I think it is a good change.

veillette commented 1 year ago

Unassigning @amanda-phet, I'll test that it is working properly in Studio.

veillette commented 1 year ago

I can confirm that the xProperty in Studio snaps to 1 decimal place when the Reference Line scrubber is released.

veillette commented 1 year ago

I realized that one downside to this behavior is that the snapping is present even when values are not on. As a result, it is not possible to put the reference line at particular point of interest.

A typical usage of the reference line would be to create a curve, and align the reference line at the maximum of f(x) and observe that derivative curve is zero at this point. The maximum of f(x) is unlikely to be at multiplies of 0.1, so it is slightly off the maximum. (see below where one cannot quite get the maximum of the integral ). image

I see two options

I would vote for two, but I am happy to be outvoted.

veillette commented 1 year ago

I thought it would be an easy issue to review and close 😞. Reassigning to @amanda-phet for input.

pixelzoom commented 1 year ago

In today's standup meeting, @amanda-phet and @catherinecarter said that they'd like to revert the snapping, and that it's OK that the displayed value and Property value may be slightly different. I've done that in the above commit.

pixelzoom commented 1 year ago

So the next question is... When the model value and the displayed value may be different, we typically both the model and displayed value in the PhET-iO API. We currently do not provide a way to get the displayed value.

@amanda-phet please choose one of these 3 options:

(1) Do nothing.

(2) Instrument referenceLineNode.numberDisplay. The Studio tree is shown below. The value will contain a lot of markup, which makes it more difficult for the client to parse, for example: "<span style='font-family: \"Times New Roman\", Times, serif;font-style: italic'>‪x‬</span> = 5.5"

screenshot_2475

(3) Add new Property referenceLineNode.xDisplayProperty. The Studio tree is shown below. The value will look like (for example): 5.5

screenshot_2476
amanda-phet commented 1 year ago

Option (3) sounds best to me. Thanks for thinking about all of these implications!

pixelzoom commented 1 year ago

Option (3) is done, closing. Feel free to have a look in master.