phetsims / faradays-electromagnetic-lab

"Faraday's Electromagnetic Lab" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
1 stars 0 forks source link

Lock/snap bar magnet to coil axis #25

Closed pixelzoom closed 7 months ago

pixelzoom commented 9 months ago

12/4/2023 design meeeting: @arouinfar @ariel-phet @kathy-phet @brent-phet @pixelzoom

@ariel-phet suggested a new feature. Mode to lock movement of bar magnet horizontally, or snap to coil axis. We should discuss this further as part of design. This would be doable within the limitations of the MathCAD model.

@ariel-phet feel free to add additional thoughts here -- learning goals that would supported, UI ideas, etc.

ariel-phet commented 9 months ago

The short reasoning is to say that in most classic physics conceptual questions involving a bar magnet, flux, and faraday's law we are generally moving the magnet towards or away from the cool of wire, along the axis of the coil (or sometimes equivalently moving the coil towards or away from the magnet, but I think giving an option to constrain the bar magnet would be sufficient. The relative motion is the important point).

Basically, if the magnet is allowed to move with off-axis motion, it confounds the issue of flux, so having an option to move the magnet locked to the coil axis allows for some conceptual simplification, and better matches the types of problems seen in an introductory electricity and magnetism course.

I think such an option should be an option, not a default, as I do think the current setup of the sim allows for nice exploration and discovery, but an option for on axis motion would likely be found useful.

pixelzoom commented 9 months ago

In Slack#DM, @terracoda mentioned that faradays-law has keyboard shortcuts for moving the bar magnet horizontally. See keyboard help below. The magnet must first be grabbed, using the grad-release interaction (space). Pressing 1, 2, or 3 then makes the magnet automatically slide horizontally. Pressing 1, 2, or 3 again changes direction. I have not figured out how to stop the auto-slide -- I tried space, return, tabbing away -- and this seems like a bug or oversight.

This feature might be useful in FEL. We'd need to work out the bugs, and make it work with collision detection. Would we use if for the bar magnet only, or also the electromagnet and pickup coils? It also involves the grab-release interaction, which we had not planned to use for this sim.

screenshot_2938
terracoda commented 9 months ago

Pressing Space, Enter, and Tab all consistently release the magnet using Firefox and MacOs Sonoma 14.1.2. Upon release the magnet stops and its outline changes to a solid pink outline.

The intended Alt Input behaviour is:

  1. Grab the magnet (Space or Enter)
  2. Press arrows to move grabbed magnet in discrete steps up, left, down or right
  3. Press 1, 2 or 3 to auto-slide grabbed magnet left or right at increasing speeds
  4. Press 1, 2, or 3 to toggle the direction of auto-sliding grabbed magnet and/or increase/decrease the speed
  5. There is no specific stop on the auto-slide. The magnet should stop if, and does stop for me on my computer: a. if it hits a boundary b. if the magnet is released (Space, Enter, Esc) or c. if the magnet loses focus and is released by pressing the Tab key d. if the magnet loses focus and is released by a click on the magnet, an other interactive objects, or in the sim anywhere non-interactive.
pixelzoom commented 9 months ago

Pressing Space, Enter, and Tab all consistently release the magnet using Firefox and MacOs Sonoma 14.1.2. Upon release the magnet stops and its outline changes to a solid pink outline.

@terracoda what version of the sim are you testing? I do see that this is true in the published version 1.4.17. But it does not behave that way in main. Can you please confirm? And if you confirm that it is indeed broken in main, please create an issue in faradays-law.

I'm testing faradays-law main branch, with macOS 14.2.1 + Chrome 120.

terracoda commented 9 months ago

I was indeed testing the published version. I'll open an issue in Faraday's Law that main has introduced issues for Alt Input.

pixelzoom commented 9 months ago

faradays-law was fixed over in https://github.com/phetsims/faradays-law/issues/226#issuecomment-1867954773. Accordiong to @jessegreenberg:

The implementation is in MagnetAutoSlideKeyboardListener.js. It is specific to faradays-law right now but it could be generalized if the same behavior is needed for another sim.

pixelzoom commented 8 months ago

@arouinfar and I discussed this feature today.

pixelzoom commented 8 months ago

1/4/24 design meeting with @arouinfar @ariel-phet @kathy-phet @pixelzoom:

The consensus was to proceed as described in https://github.com/phetsims/faradays-electromagnetic-lab/issues/25#issuecomment-1875815968.

pixelzoom commented 8 months ago

https://github.com/phetsims/faradays-electromagnetic-lab/issues/10 (drag bonds) is a prerequisite to this issue. Horizontal dragging will be accomplished via dragBounds with height=0.

pixelzoom commented 8 months ago

The 1/2/3 hotkey has been move to https://github.com/phetsims/faradays-electromagnetic-lab/issues/54, since it is independent of the feature that this issue is tracking.

pixelzoom commented 8 months ago

In the above commits, I implemented everything expect the constrained dragging for this feature. I gave @arouinfar a preview on Zoom, and I'm on the right track. So I'll continue with finishing this off.

pixelzoom commented 8 months ago

This feature has been implemented. You can test-drive it in the Pickup Coil and Transformer screens, in phettest or in 1.0.0-dev.9. See the "Lock to Axis" checkbox in the lower-right control panel.

@arouinfar @kathy-phet @ariel-phet please test-drive before 1/25 design meeting.

pixelzoom commented 8 months ago

1/25/2024 design meeting: @arouinfar @kathy-phet @ariel-phet @pixelzoom

Consensus was that everyone is happy with this feature. We may want to move the positions of the magnet and pickup coil up a bit, to feel more centered in the screen. We'll probably defer that until we calibrate the light bulb to display longer rays. (Tracking in https://github.com/phetsims/faradays-electromagnetic-lab/issues/64).

terracoda commented 7 months ago

@pixelzoom, I do not see the 1-2-3 working in that dev 9 version. Is it supposed to work?

terracoda commented 7 months ago

The behaviour @ariel-phet described in https://github.com/phetsims/faradays-electromagnetic-lab/issues/25#issuecomment-1842993199 seemed to match the auto-glide behavior in FL.

pixelzoom commented 7 months ago

@terracoda The 1/2/3 hotkeys feature was broken out into issue https://github.com/phetsims/faradays-electromagnetic-lab/issues/54 about 2 weeks ago, because it is independent of whether dragging is locked -- the magnet (and coil) are movable regardless of whether they are locked to the pickup coil axis.

In https://github.com/phetsims/faradays-electromagnetic-lab/issues/54#issuecomment-1911171929, the design team's consensus was:

The 1/2/3 hotkeys would be relatively expensive to implement, and would not add significantly to what we can accomplish with KeyboardDragListener dragVelocity and shiftDragVelocity. @arouinfar and I will work on tuning those values.

If you'd like to discuss further, let's continue in https://github.com/phetsims/faradays-electromagnetic-lab/issues/54. Thanks!

Re-closing this issue.