Open arouinfar opened 7 years ago
I have looked into this and find it hard to come up with a solution that wouldn't either change a lot of the model or worsen performance. How important is this?
Thanks @andrea-phet. I think that's really a question for @kathy-phet or @ariel-phet, so I'm reassigning the issue to them.
I think its worth a conversation with JO to see if he sees an option.
I think it would only need to have this smoother action during a "slow mode" setting, not say adding a smaller timestep at all times.
Sounds good @kathy-phet! Reassigning to @andrea-phet and @jonathanolson.
There are a few options to handle this.
I recommended (very briefly) interpolation between model steps in https://github.com/phetsims/projectile-motion/issues/49 (like wave-on-a-string and potentially other simulations that have a larger fixed-DT timestep, smooth animation between those is desired).
The proper way to do this is to compute the two large-timestep states that we are "between", determine how far from the "start" to the "end" we are in every timestep, and blend those two states together to determine where the projectile should be.
Allowing the trajectory to adjust in-between states would be complicated and probably not visibly noticeable, so computing the trajectory steps as they are now sounds good (with the added interpolation added on).
Looking into whether we can include air friction into a fully integration-based approach may allow for enough precision to get by with variable timesteps (e.g. Pendulum Lab, where the model includes friction in the Runge Kutta integration which gives the necessary precision).
This would allow the projectile's motion to be very smooth, but a bit of extra effort would be required to evenly space the visible points on the path.
Also important to note is that Pendulum Lab's integration needs 10 steps per frame to get the desired ~11 digits of precision, so this could increase computational cost (whereas interpolation would have the highest potential performance). NOTE: This is probably why we can't just "switch to a smaller timestep for slow motion", because it wouldn't land in the same place, and readouts may show the difference in trajectories.
My first thoughts would be to look into the variable-timestep model (as the current way of handling friction leads to accumulation of error due to the timesteps).
Any objections?
@jonathanolson spoke with @kathy-phet and it sounds like it's worth some investigation (possibly in a branch in case things get messy). Do you have time to work with @andrea-phet and @jbphet on this?
@ariel-phet - We could also consider improvements in slow motion for a version 1.1 and release with the current model for this school year fall use.
@andrea-phet I think improvements for slow motion are fine to leave for a later version (step is far more beneficial in this sim than slow motion in my opinion)
OK -- Deferred it is!
Looking at this again since the lack of smoothness in slow motion is noticeable. I was able to significantly improve the smoothness of slow motion by decreasing the TIME_PER_DATA_POINT constant (see video below). This seems like a start but needs to be discussed and optimized. Will discuss with @zepumph.
TIME_PER_DATA_POINT = 25ms
TIME_PER_DATA_POINT = 10ms
@zepumph and I met with @jonathanolson to discuss this, based on this post - https://github.com/phetsims/projectile-motion/issues/124#issuecomment-321070508
We discussed the following:
With this in mind, we recommend changing the TIME_PER_DATA_POINT to a lower value, and dealing with potential consequences that come with creating additional data points as they arise.
Closing this issue as slow motion is much smoother with these changes and we haven't encountered any performance issues.
TIME_PER_DATA_POINT is currently set to 12 ms. Slow motion is much smoother with these changes and we haven't encountered any performance issues. @arouinfar can you review slow motion?
@kathy-phet said:
I agree that slow motion could look smoother, but I think the dots also create an illusion that the animation is a little jerkier than it actually is. Regardless, I think it would be good for @andrea-phet to look into @kathy-phet's suggestion.