I decided to make some Physics/Math Simulations for Hack Club's Axiom ysws! Below are descriptions of the simulations I made.
Doing physics calculations for projectile motion with drag by hand is tedious and far less fun than simply putting in a few values into text boxes and clicking "Launch!" As a result, I made a simulation which accounts for drag dependent on the actual physical properties of the object being launched. The simulation takes into account the object's radius (assuming it to be spherical by default) and otherwise the drag coefficient can be manually specified. The object's mass can also be specified, which would change the effect of drag. There are presets, for approximately spherical objects: baseball, golf ball, soccer ball, basketball, and tennis ball, which populate the values for the radius and mass fields for the simulation. To run the sim, either select a preset, or manually specify, the projectile's mass, radius, launch angle, and initial velocity, and click Launch! Upon launching the projectile, it is rendered as a blue circle with a white arc behind it representing its trajectory. There are also vectors rendered, with the red vector representing the velocity and the yellow vector representing the force of drag. When the projectile lands, the simulation automatically stops, and the final statistics are shown below the input fields for the various parameters of the simulation, such as the time the projectile took, its final velocity, its total horizontal distance, the apex height of its path, and the length of the path it traveled.ed.
Watching balls collide with no friction is always fun! I made a momentum simulation to demonstrate collision physics with two perfectly spherical objects. The simulation allows specifying the mass of both spheres (represented as circles), and their initial velocities. But a simulation that only does that would be quite boring; so, instead, there is a cinematic slowdown effect which slows the simulation time down so the collision is crisply visible as it happens. As the collision occurs, the tangent line of the collision is briefly shown, along with the collision number (1 for first collision, etc.). Drag and friction are available in the sim, but are off by default so the sim runs for longer. To run the simulation, specify both objects' masses, velocities, and initial angles, and click the Collide! button. Upon running the simulation, the objects are rendered as a blue and a green circle, with a red vector representing the velocity. Similar to the Projectile Motion Simulation, this sim also has a pause button for closer analysis. Additionally, statistics are shown at the bottom of the webpage, such as the velocities of the spheres, the simulation runtime, the number of collisions, and the spheres' coordinate positions.s.
What could be better than watching two spheres collide with no friction or drag? How about five hundred little colored spheres colliding? The particle simulation is effectively an extension of the momentum simulation; the difference being there are far more objects. In the particle sim, instead of rendering a bunch of velocity vectors for every single particle, the particles are colored dependent on their speeds; slow particles are red, faster ones are green, and really fast ones are indigo! This simulation is far simpler than the others; there is no drag, and no friction, however the user can add as many particles as the puny JavaScript engine can handle. The sim shows framerate, frametime, and the total number of particles in the top right corner, so fine-tuning the amount of particles to keep the sim running at 60 FPS is trivial. Simply click Launch! to run the simulation; no configuration is necessary beforehand. The particles are rendered as circles, with their radii dependent on the mass (unlike the momentum simulation, the particles can have differing masses). The minimum and maximum mass fields adjust the masses of any new particles being added to the simulation, and thus their sizes as well, since a particle with mass 10 would have a radius of 10 as well, and so on. This sim is certainly the most satisfying; watching the particles calmly bounce around, hitting each other, and changing colors makes it feel quite mesmerizing.
One of my friends gave me the idea to have a gravity simulation, and I certainly enjoyed making it. The gravity sim has two types of objects, contrasting the previous three simulations: large planets and small, green, 1-kg objects. The planets have proper gravitational physics applied so the particles are realistically attracted to them; upon launching the simulation, there are two planets, both having mass 10^16 kg. The planets can be dragged around to visually show how the gravitational field changes; right-clicking anywhere on the sim enables a test point, which shows the gravitational field strength at that exact location, and right-clicking the data hides it. Similar to the particle sim, objects can be added and removed as well, and clicking Gravitate! runs the simulation, without any need for configuration as with the projectile motion and momentum simulations. The simulation renders yellow gravitational vectors to show how the planets affect the motion of the objects, and the velocity vectors for each object can also be shown. It is also possible to make the objects' collisions inelastic, so eventually they all settle on the corresponding planets. The gravity sim also slows down with too many objects; thus, a framerate/frametime counter has been provided, as with the Particle Simulation.