Open KatieWoe opened 6 years ago
Regarding sharp track kinks, @ariel-phet said in https://github.com/phetsims/energy-skate-park-basics/issues/434
The super sharp kink is not very pedagogically useful. I agree it would be nice if it were disallowed, but it definitely was tricky to get the current algorithm for track smoothing working as @samreid pointed out. You are definitely welcome to work more on this problem, but I think I would give it a limit. Something like 5-6 hours of investigation, and if you don't have a promising solution/direction, leave it alone.
I definitely do not think you need to worry about some odd behavior while dragging the track. If a kink or such happens while the skater is on the track and the track is being dragged, I don't think we will easily be able to avoid all those potential edge cases. If you work on (1) only worry about static cases. If some weirdness happens in some edge cases while the skater is moving and the track is being dragged, that is acceptable.
In the tracks found in https://github.com/phetsims/energy-skate-park-basics/issues/434, the smoothing algorithm is returning that smoothing was successful, so I would like to understand why this is considered smooth:
The correction loop:
while ( this.getMinimumRadiusOfCurvature() < MAXIMUM_ACCEPTABLE_RADIUS_OF_CURVATURE && numTries < MAX_TRIES ) {...}
this.getMinimumRadiusOfCurvature()
is 0.031, MAXIUMUM_ACCEPTABLE_RADIUS_OF_CURVATURE
is 0.3.
The problem may be with getMinRadiusOfCurvature, which can return larger numbers occasionally like in https://github.com/phetsims/energy-skate-park-basics/issues/440#issuecomment-429990259, and then much smaller numbers with seemingly identical tracks, causing a re-smooth.
If I increase numDivisions in getMinimumRadiusOfCurvature to 800, curvatures are more accurate. But smoothPointOfHighestCurvature is now unable to find a control point.
I am abut 2 hours into this, which helped me understand how the current algoritm works and try a couple of solutions.
From this issue and #434, there are two reasons that kinks might show up, the track is incorrectly considered smooth by the model, and the model is unable to smooth a kinked track.
The first case will happen because of the resolution of getMinimumRadiusOfCurvature, which breaks the spline into divisions and finds the smallest radius by calculating radius at each division. For cases like https://github.com/phetsims/energy-skate-park-basics/issues/440#issuecomment-429990259, the spike is in between two divisions and it is missed. I tried doubling/tripling the number of divisions, and this fixed one test track I added, but I can still consistently create tracks like the one in https://github.com/phetsims/energy-skate-park-basics/issues/440#issuecomment-429990259. And increasing this value significantly will probably have performance implications. I wonder if it is possible to do more searching around local max/min of the track?
For the second case, I tried adding a second correction step where we find the point of highest curvature then if surrounded by two other points, try adjusting the surrounding points to "pull apart" the kink. This worked OK in some cases, but wasn't able to correct tracks like the one in https://github.com/phetsims/energy-skate-park-basics/issues/440#issue-366382898. And sometimes pulling apart more than one control point made radically different tracks than what I was trying to create.
Ill spend a little more time trying to find radii along the spline focusing on local minima/maxima for the first case, but I won't spend more time on the second case for now.
I wonder if it is possible to do more searching around local max/min of the track?
I tried this and it is working well so I am going to commit. In getMinimumRadiusOfCurvature and getUWithHighestCurvature, we find local minima and maxima and scour those areas with smaller divisions so that we are less likely to miss small radius of curvature when there are spikes in the track. I am no longer able to produce tracks like https://github.com/phetsims/energy-skate-park-basics/issues/440#issuecomment-429990259.
I don't think this will have much of a performance impact because these functions currently use 400 samples, and this only adds 10 samples per local extrema.
I am still able to produce cases like https://github.com/phetsims/energy-skate-park-basics/issues/440#issue-366382898, the case where smooth
is unable to smooth the track. I am out of time from https://github.com/phetsims/energy-skate-park-basics/issues/440#issuecomment-429968287 and don't have any good ideas to handle that case. If we want to address it, it may be helpful to discuss with @samreid or others at a design meeting how to prevent non-pedagogically useful tracks.
Pinging @ariel-phet and @samreid so they are aware of this status update, and adding the deferred label, we may pick this up again in ESP.
Got it, thanks @jessegreenberg. I'll wait to hear from @ariel-phet if I should help on this issue.
It seems like this issue is probably still outside the scope of the upcoming region and culture publication. Leaving as deferred.
Test device: Dell Laptop Operating System: Win 10 Browser: Chrome Problem description: For https://github.com/phetsims/QA/issues/134 after discussion in https://github.com/phetsims/energy-skate-park-basics/issues/418#issuecomment-426487600. Related to https://github.com/phetsims/energy-skate-park-basics/issues/193. It is possible to still create sharp vertex in the playground screen. The solution to the previous issue seemed to be that if there was a sharp point in the track a movable point would jump to a new position, eliminating the point. However, if that point jumps to a position that also creates a sharp point, it is not recognized and remains sharp. Steps to reproduce:
Screenshots: Video: https://drive.google.com/file/d/1R64SEbwm_CE0nETaQLbzdD9plVwN7kl_/view?usp=sharing
Troubleshooting information (do not edit):