phetsims / collision-lab

"Collision Lab" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
6 stars 4 forks source link

Balls may still have velocity if they read 0 #182

Closed KatieWoe closed 3 years ago

KatieWoe commented 4 years ago

Test device iPad 6th Gen Operating System iPadOS 14.1 Browser Safari Problem description For https://github.com/phetsims/QA/issues/562 It is possible for balls to still have a slight amount of velocity and be moving very slowly even if their data says they have zero velocity. This can be seen with the velocity arrow being somewhat visible and if you wait long enough you can see the movement. This is best done on the third screen with 5% elasticity.

Visuals ezgif com-gif-maker (1)

jonathanolson commented 4 years ago

This seems like a design decision... 0.00 currently means "less than 0.005" due to rounding. @arouinfar how should this be handled? I could imagine "have a way of showing non-zero but small" velocities, OR some way of zeroing out low velocities (or their components), OR leaving as-is.

arouinfar commented 4 years ago

This is similar to https://github.com/phetsims/collision-lab/issues/162. This is the nature of precision and rounding, which I'll make note of in the Teacher Tips.

The only thing I think we could do would be to display < 0.01 when the values are small but non-zero. I think we would need to do this for velocity, momentum, and KE. The worry I have with the approach is that we might not be able to easily detect when the ball comes to rest to switch the displays to 0.00. @jonathanolson what are your thoughts on this?

oliver-phet commented 4 years ago

Just to document, a user wrote to phethelp:

there is a rounding error in the HTML5 collision phet so the total momenta before and after collision is slightly different sometimes See this screenshot: m1 = 2.00, v1 = 0.14 and p1 = 0.29

Students may get confused since m1*v1 = 0.28.

Not sure how to fix this myself. Other than telling students that there is some rounding artifact. Use the p1 reported in phet and not use the m1*v1 equation. after collision

arouinfar commented 4 years ago

@oliver-phet there isn't anything we can do here. The mass in the model is exactly 2.00 kg. However, the velocity is some long decimal that rounds to 0.14, which means it's actually anything in the range of [0.135, 0.145). The displayed momentum is the result of multiplying 2.00 by the actual value of velocity which is then rounded to two decimal places in the display. For example, the velocity in the model might actually be 0.14366789 which means the momentum would be 0.28733578 which rounds to the 0.29 shown in the display.

When users directly set the velocity by typing in a value or dragging the vector, the velocity will be exactly the displayed value. However, as soon as balls collide, the velocity will no longer be a nice, round number.

jonathanolson commented 4 years ago

The only thing I think we could do would be to display < 0.01 when the values are small but non-zero. I think we would need to do this for velocity, momentum, and KE. The worry I have with the approach is that we might not be able to easily detect when the ball comes to rest to switch the displays to 0.00. @jonathanolson what are your thoughts on this?

This seems very doable, but we'd presumably have a very low threshold for "at rest" (e.g. 1e-8).

jonathanolson commented 4 years ago

Design meeting: we'll show "< 0.01" when it is below that amount AND non-zero.

jonathanolson commented 3 years ago

Implemented in the above commit. @arouinfar can you let me know how this looks?

arouinfar commented 3 years ago

I reviewed master and have a few thoughts.

The first issue is likely trivial to address, but the second calls into question this entire approach. I think I'd rather just let small numbers show up as 0.00 and clarify things in the Teacher Tips. @ariel-phet what do you think?

ariel-phet commented 3 years ago

@arouinfar what about going with a "~0.00" approach when it is not truly zero. I agree, with just labelling position as zero, but for velocity "~0.00" might be nice when it is actually moving visibly.

arouinfar commented 3 years ago

@arouinfar what about going with a "~0.00" approach when it is not truly zero.

That's brilliant! I think this will work really well for the velocity and momentum. Would we also use ~0.00 for things like the KE and magnitudes displayed with Values checked, or would we want to stick with < 0.01 (assuming it isn't overly complicated to do)?

ariel-phet commented 3 years ago

@arouinfar I don't actually have a strong opinion, but probably best to just be consistent. I think ~0.00 could work well in all those cases if we wanted consistency. But for KE and magnitudes I would be fine with <0.01 as well.

arouinfar commented 3 years ago

Ok, let's go with ~0.00 for consistency.

@jonathanolson let's display ~0.00 for all non-zero values within (-0.005, 0.005), except for position.

jonathanolson commented 3 years ago

Should be implemented above。

arouinfar commented 3 years ago

Looks great @jonathanolson! I think this is ready for QA in the next testing cycle.

KatieWoe commented 3 years ago

This looks like it was implemented in 1.1.0 dev.13. I noticed that the ~ can look a bit like - in certain fonts. @arouinfar I don't know if that is worth looking at.

maybenegative
arouinfar commented 3 years ago

Thanks @KatieWoe. I don't think there's much we can do to control the font, but in your screenshot the ~ is quite a bit longer than - which helps keep them differentiable.