phetsims / graphing-quadratics

"Graphing Quadratics" is an educational simulation in HTML5, by PhET Interactive Simulations.
MIT License
1 stars 4 forks source link

Make Point On Parabola snap to displayed x value, like Point Tool. #172

Closed pixelzoom closed 3 years ago

pixelzoom commented 3 years ago

In https://github.com/phetsims/graphing-quadratics/issues/169#issuecomment-909518229, @stemilymill reported:

https://github.com/phetsims/qa/issues/704

The snapping behavior of the point tool is correct, but I noticed that in the Focus & Diretrix screen, the Point on Parabola graph option shows the old behavior with multiple y-values for one x-value. @amanda-phet is this ok, or should the behavior match the point tool?

same x different y graph options point on parabola

pixelzoom commented 3 years ago

This can certainly be done, but it a new issues.

@amanda-phet is this something that you want done? And do you want it for the 1.2 release?

EDIT: I recommend that we do this.

pixelzoom commented 3 years ago

Note to self...

This involves taking this bit of code from PointToolNode.PointToolDragListener:

            // We will be snapping the x value as it will be displayed by the point tool.
            // See See https://github.com/phetsims/graphing-quadratics/issues/169.
            let x = Utils.toFixedNumber( position.x, GQConstants.POINT_TOOL_DECIMALS );
...
            const y = snapQuadratic.solveY( x );
            position = new Vector2( x, y );

... and adapting it to PointOnParabolaManipulator.PointOnParabolaDragListener. Be sure to use GQConstants.POINT_ON_PARABOLA_DECIMALS instead of GQConstants.POINT_TOOL_DECIMALS.

amanda-phet commented 3 years ago

I think we should make this change since the goals of the point on parabola are very similar to the point tool.

pixelzoom commented 3 years ago

Done in master and 1.2 branches. @amanda-phet please review in master.

amanda-phet commented 3 years ago

Looks great!

pixelzoom commented 3 years ago

Ready for testing in the next RC. To verify:

  1. Go to the Focus & Directrix screen
  2. Check the "Point on Parabola" checkbox
  3. Keep the "Coordinates" checkbox checked
  4. Move the "Point on Parabola" manipulator (red sphere) along the curve. Verify that for each x coordinate shown, you only see one y coordinate value.
  5. Verify with various configurations of the curve, especially ones with a steep slope.
Nancy-Salpepi commented 3 years ago

I was unable to find any instances where the same x value had multiple y values. When the y coordinate value changed, so did the x value.