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

1D set-ups not working on 2D screen (vertical velocity creeps in) #136

Closed kathy-phet closed 4 years ago

kathy-phet commented 4 years ago

In the 2D screen, we should be able to set up a 1D situation, and ball collisions should not introduce motion in the other dimension if they are centered on each other with no y components of velocity. However after 2 collisions the balls start to have vertical velocity. Found at design meeting last week. Can you take a look at this Brandon? Fixing this physics is blocking for publishing the prototype. Thanks.

arouinfar commented 4 years ago

Related to https://github.com/phetsims/QA/issues/524

@brandonLi8 I tested this in master before design meeting yesterday, and the 1D collisions were behaving correctly on the 2D screens. However, it's definitely buggy in the latest dev.

arouinfar commented 4 years ago

@brandonLi8 actually, I think I figured out why it was working for me yesterday. If you use the keypad to set the y-position and Vy to zero, 1D collisions behave normally. If you drag the ball or velocity vector with the mouse, the actual value probably just rounds to zero.

arouinfar commented 4 years ago

Is it possible to make sure the model values exactly match the view when dragging the balls or vectors?

brandonLi8 commented 4 years ago

Is it possible to make sure the model values exactly match the view when dragging the balls or vectors?

Technically this is possible, but I think it could be ugly. Essentially, balls would be snapping to super small grid lines (when grid is off) and to the normal grid lines (when grid is on). We would also have to snap the velocity to the super small grid-lines. From one of our design meetings, I remember that we didn't want to snap the velocity vector but I don't remember why.

I haven't been able to reproduce this locally. @arouinfar can you describe steps to reproduce or comment a video?

kathy-phet commented 4 years ago

OK, I see what the issue is. I think the interaction could be improved with this sort of approach:

I think that would work to avoid this situation of thinking you are doing 1D but not succeeding at it?

brandonLi8 commented 4 years ago

Good to know that this isn't an issue with the physics engine, rather an issue with setting up balls.

@kathy-phet I think snapping ball position/velocity to the nearest hundredth decimal on mouse release sounds good. The only part that I'm concerned about is this point:

it would need to behave nicely with the other code that prevents overlap.

I'm not quite sure how this would work. One way (the most feasible) would be to snap to the nearest 0.01 only when a ball is NOT dropped on top of other balls. If it is dropped on top of other balls, the same "bumping" code is used where the ball is moved next to the overlapping ball. @arouinfar @kathy-phet thoughts?

kathy-phet commented 4 years ago

Hi Brandon, Could the bumping code round after bump with a test that if normal rounding creates an overlap that it does rounding in the other direction? So if 1.28903 rounds to 1.29 and that has overlap - that it rounds in the other direction to 1.28 - and if that has overlap, it does something else so that it doesn't end in an infinite loop?

brandonLi8 commented 4 years ago

@kathy-phet @arouinfar this should be done in the commits above. Please review in master.

Here is exactly how it works (if you are curious):

kathy-phet commented 4 years ago

Thanks - this seems like it will work. I'll check it out!

kathy-phet commented 4 years ago

Works great on my quick test!! Awesome - so nice to set it with just the mouse and see the expected 1D behavior. Thank you!

arouinfar commented 4 years ago

@brandonLi8 this is looking really nice!