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

MAX_TILT is not respected. #245

Closed veillette closed 1 year ago

veillette commented 1 year ago

In tilt mode, the maximum tilt of the line should be 45 degrees. However the max tilt is not respected if the curve at at x=0 is not y=0.

image

veillette commented 1 year ago

This was noted while trying to reproduce https://github.com/phetsims/calculus-grapher/issues/241.

veillette commented 1 year ago

The tilt mode makes an assumption that the point at x=0 is zero, which is the source of the problem.

veillette commented 1 year ago

Although the problem was easily identified, it took me a while to come to a solution. As as result of the commit above, the maxTilt in CalculusGrapherQueryParameters is no longer an angle but a slope. The maxTilt value is set to 3

It turns out to be simpler to calculate offsets based on difference in slopes rather than difference in angles.

veillette commented 1 year ago

I have tested it a bit and it works as expected. The maximum slope that can be seen by manipulated the Shift and Tilt mode is the following. image

veillette commented 1 year ago

The commit for this issue can be found https://github.com/phetsims/calculus-grapher/commit/e9a2b4bde836940df291c48bb37abece0fb77c62

The previous implementation limited the relative slope (measure by the added slope added by the user) to be below a threshold. However, successive user manipulations would allow a user to create a slope that was nearly infinite. The new approach is to determine the absolute slope of the curve and ensure that it is never above a threshold (currently set to 3). Assigning to @pixelzoom to review and close if appropriate.

pixelzoom commented 1 year ago

Looks and behaves reasonably to me! Closing.