I've been messing around with Processing a little bit lately. In my last post, I animated the double pendulum, and it became pretty clear that I had messed up the math somewhere in deriving the equations of motion for the system. This time, I wanted to show the vector field around a point charge, or a pair of point charges. Here's a gif of the processing sketch I coded up:
Overall, I'm pretty happy with this. Note that for each of the point charges, I don't calculate the field inside some predefined radius. That doesn't mean that the field isn't calculated in that area for the other point charge. That's why we can see field lines inside this 'critical radius' when the two particles get close to each other. Instead of representing the magnitude of the vectors with a length, I think that I should represent the magnitude of the vectors with colors. This would allow me to deal with the fact that the $1/r^{2}$ function blows up as you approach zero a little better. If you'd like to see the code, hit me up and I'll throw it up on github.
Update: I added colored vectors to my code, such that the magnitudes of the vectors are reflected in color, not the length of the arrow. Here's a new gif that shows this functionality.
No comments:
Post a Comment