Closed amanda-phet closed 3 years ago
Code that handles snapping to the quadratic is in PointToolNode.js:
// If we're on the graph and the contents of the graph are visible...
if ( graph.contains( position ) && graphContentsVisibleProperty.value ) {
// snap to a quadratic, if we're close enough
const snapQuadratic = pointTool.getQuadraticNear( position,
GQQueryParameters.snapOffDistance, GQQueryParameters.snapOnDistance );
if ( snapQuadratic ) {
position = snapQuadratic.getClosestPoint( position );
}
}
Done in master and 1.2 branches. This turned out to be very easy to add.
@amanda-phet @kathy-phet please review in master.
@kathy-phet would like to make it easier to snap to integer x values. Full Slack discussion below. I'm going to add a query parameter that lets you set a tolerance for snapping x to integers.
In the above commits (to master and 1.2 branches), I added snapping of x to integer values. This issue is now labeled "blocks-sim-publication", until we wrap up this issue.
Query parameter xSnapTolerance
has a range of [0,0.5], and a default of 0.05 (as suggested by @kathy-phet). When the x coordinate (as displayed on the point tool) is xSnapTolerance
or closer to an integer value, it will snap to that integer value. Setting this to 0 effectively disables the snapping to integers.
Reminder that this is an internal query parameter. If you provide an illegal value, it will complain in the browser console, and ignore your value. So you should probably experiment with the console open.
Finallly... The default value of 0.05 feels to large to me, especially since the precision of the point tool is 0.01. It makes it impossible to get to x values that are close to integers.
@amanda-phet @kathy-phet please review in master. Let me know what you want to change.
When I experiment with xSnapTolerance
it seems like the point tool just skips over the values close to the integer, which is strange to me. Even with a small value like .02 it is strange to me, so I would prefer to not add any snapping to the point tool.
@amanda-phet I agree that it feels strange when it skips over x values close to integers. Since the point tool displays values to 2 decimal places (0.01), I think that xSnapTolerance
needs to be < 0.01. Could you please try ?xSnapTolerance=0.00999999
and see if that feels better, and still snaps to x integers?
I hadn't considered such a small value! I am comparing xSnapTolerance=0
and xSnapTolerance=0.00999999
and I don't notice a difference. Is it still valuable to have a snap tolerance, even if I don't really feel it, because it guarantees that I'll be able to put the point tool on the integer value? If so, I think 0.01 seems to work just fine. It doesn't feel skippy to me, but it also doesn't feel snappy. I just know I can get to the integer value.
If you don't notice a difference, then my recommendation is to ditch the xSnapTolerance
feature.
I spoke with @kathy-phet and @amanda-phet separately.
@kathy-phet like the behavior with xSnapTolerance=0.00999999
.
@amanda-phet didn't notice a difference between xSnapTolerance=0.00999999
and xSnapTolerance=0
(effectively disabled) but is OK with keeping the feature.
I'm going to remove the query parameter, change the logic from <= to <, and use 0.01 as the snap interval.
Done in the above commit.
Ready for testing in the next RC. To test, while sliding a point tool along a curve:
-x values change when y values do -I can place point tool at integer x values
@pixelzoom I'm using https://phet-dev.colorado.edu/html/graphing-quadratics/1.2.0-rc.2/phet/graphing-quadratics_en_phet.html and the point tool is behaving as though it is snapping at .05. This is noticeable to me because yesterday I was easily able to get values around an integer and can't with this version.
Adding on to what Amanda is saying, this snapping behavior seems to happen around the x whole integer values, which is mostly what seems odd to me.
I see what you are saying @amanda-phet. The snapping occurs .05 away from an integer. Otherwise, all x values can be seen.
I'll need some specific examples. There's are lots of different varieties of snapping going on here.
Oh rats, I see what happened. I cleaned things up in master, forgot to cherry-pick https://github.com/phetsims/graphing-quadratics/commit/f6a6dc5d8864aece9650fef279f070f855a0a385 to the 1.2 branch. So the completed work didn't make it into 1.2.0-rc.2.
We'll need another RC. 😡
OK...so no need for my video then?
No @Nancy-Salpepi, but thank you. No need to do anything else with this issue until the next RC.
I've patched the 1.2 branch in the above commit. Ready for testing in the next RC.
On second thought... Before we published the next RC, I'd like @amanda-phet to verify the behavior again in master please.
Looks good on phettest now.
Great, thanks @amanda-phet. Ready for the next RC.
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?
Thanks @stemilymill, good observation about the Point On Parabola.
While this behavior would be similar to the Point Tool, it does not involve the Point Tool, and would be a new feature. So I've move that change to https://github.com/phetsims/graphing-quadratics/issues/172.
Closing this issue, since the Point Tool has been verified.
@kathy-phet brought up concerns about the point tool displaying inconsistent values. We know this is because in these cases, not all locations are at exactly x=3 (could actually be 2.999 or 3.001), and the y-value is changing faster than the x-value.
To improve usability, and assist with the goal of using the point tool to identify solutions to the quadratic, @pixelzoom and I brainstormed a few different solutions.
The solution we like best is to do two things: (1) snap the tool to the x-value being displayed in the point tool, so if it says x=3 the tool will be at x=3 (2) calculate the y-value in the point tool using the x-value and the quadratic
This might result in the tool seeming a little jumpy on steep curves, but it seems like it will just be a few pixels and not too dramatic.