Download ModelDownload SourceembedFeedback


Intro Page

Welcome to Magnetic Mini Golf!

This program allows a player to play a version of Putt Putt with a twist: the ball behaves like a point charge in that it responds to magnetic fields. This game has two levels: regular and challenge. For the first level, the first magnetic field is placed in the lighter green region seen from the overhead view. The field is aimed into the ground (or screen). This causes the charged ball to veer in either a counterclockwise or clockwise direction depending on the direction of its approach to the field. The ball obeys the right hand rule, such that it will travel in a clockwise motion when approaching from the left and counterclockwise from the right. Level two adds a teal magnetic field in the opposite direction.

The ball's motion is also affected by friction with the green. This inhibited acceleration causes the ball to slow and eventually stop, as normal golf balls are wont to do.

The rules are simple. Putt the ball in the hole in as few strokes as possible!

Players may change a few factors, the velocity of the putt, the direction of the ball, and the original ball placement, in order to accomplish this goal. The velocity is controlled by the input field, and the angle by the dial. Enter must be pressed after changing the velocity. Both of these variables, however, can also be manipulated by the hot spot on the tip of the arrow after the first shot. (I prefered that players use the panel elements at least once.)

Once the player has selected the parameters, they can press the Putt button to hit the ball. There is a reset button in case things go too awry in a particular round.

The counter in the bottom right corner keeps track of the number of strokes. Note that if the ball leaves the green, the player will incur a penalty stroke!


The acceleration of the ball is calcuated by utilizing the force equation F=qv x B, used when a point charge interacts with a magnetic field. The cross product requires the right hand rule behavior of the ball. The magnetic contribution to the acceleration in the ODE is set so that it equals q*v*B/m only when in the specific light green region. The B value is negative in the teal region, reversing the direction.

Friction is added to the acceleration calculation with simply subtracting b*v/m, where b is a friction coefficient set to .5 in this simulation. I then wrote code to prevent the ball from infinitely approaching a zero velocity. The program sets the velocity of the ball to zero when its velocity slows to less than .05. It uses this information to allow the player to putt once more.


The example programs I  looked at were working with arrays, and I was not. I found it challenging at times just to use code specific to a single ball, oddly enough.

The theta dial turned out to be the biggest time sink in proportion to its importance in the program. It's settings were challenging for me to configure.

I also had trouble letting go of the idea that every program needs a for-loop, more or less.

The events' collisions were the most challenging aspect of the programming. I  had to be much more careful with that code and felt like what I was writing was often redundant. I would remove the repeated code only to find the program had ceased to work. That was frustrating, what with my gut saying something was wrong with my setup. The coding may be clunky in places, perhaps, but I wanted to stick to the functioning game.


For Teachers


Software Requirements


Android iOS Windows MacOS
with best with Chrome Chrome Chrome Chrome
support fullscreen? Yes. Chrome/Opera No. Firefox/ Sumsung Internet Not yet Yes Yes
cannot work on some mobile browser that don't understand JavaScript such as..... cannot work on Internet Explorer 9 and below



Hannah Thigpen; Fremont Teng; Loo Kang Wee

end faq

Sample Learning Goals


For Teachers



Goal of the Game

To putt the ball
into the hole


Drag the red arrow head to adjust the velocity of the ball.

The magnitude of velocity is adjusted by the size of the arrow,
while the direction is the direction.


Press the putt button to fire off the ball into the hole!

Notice as the size of the arrow decreases over time.

Toggling Full Screen

Double clicking anywhere on the screen to toggle full screen.

Reset Button

Resets the simulation.






Other Resources


end faq

1 1 1 1 1 1 1 1 1 1 Rating 0.00 (0 Votes)