# A Variety of 3D Simulators

Hello there! This website hosts a few 3D concept projects. They were all originally in cpp and opengl however I ported some to threejs if they didn't use too many models. These also work on mobile, so have fun!

* IMPORTANT: To view the simulations, you need to use either a trackpad, a mouse or a touch screen. Using gestures on a trackpad, a mouse wheel + right-click or a touch screen you can move around the 3D view. Use the sliders to alter parameters.*

## Introduction

Most of the simulations available on the internet are two-dimensional – this makes it very hard to imagine these phenomena happening in our world. Simulations allow us to illustrate dynamic processes, giving insight to the nature of certain physical laws. I therefore wanted to create ones that are usable and intuitive. I took inspiration from museum exhibits and video games when creating a minimalist aesthetic, utilizing touch controls and intuitive menus to display accurate, readable data.

## Theory of Simulations

Almost all the simulations utilize *Numerical Methods*, which are algorithms that are able to generate motion from physical equations and initial conditions. The specific ones used in these simulations are the Runge-Kutta Method and the Verlet Velocity method.

Source code for the Numerical methods can be found here, however I got most of my ideas for ODE simulation from * Elementary Differential Equations And Boundary Value Problems *. The computations done by the numerical methods are all done client-side through JavaScript and graphically represented using the WebGL-based ThreeJs graphics library.

## Descriptions

# Ideal Gas

As a kid I loved inflating balloons and compressing them at parties (this habit continued to modern day). However, as a student of physics it is quite unintuitive to how the gas molecules change in behavior due to the external changes. This simulation aims to visualize gas interactions at a comprehendible scale.

An ideal gas is a model of a theoretical gas composed of many randomly moving point particles whose only interactions are perfectly elastic collisions.

The model allows a very simple relation between pressure (**P**), volume (**V**), and temperature (**T**) as follows:

** PV = nRT **

Of course, this model is *ideal*, so it doesn't take into account inter-molecular forces, collisions between molecules, density etc.

# Three Body Problem

The three body problem is quite famous in celestial mechanics, as it is impossible to solve without relying on numerical methods. This problem as come up particularly when trying to model the system of the Earth, Sun and Moon.

A practical application for this simulation would be prediction eclipses, using intial conditions of the Earth-Sun-Moon system to determine when an eclipse will occur

Modeling the orbit of three celestial bodies requires one to use a numerical method to model the equations of motion. In this case, * symplectic euler * was used to solve the following equations:

The simulation also traces the path of the planets. In my opinion, the shapes are quite aesthetic, so have fun playing with the sliders!

# Single Oscillating Spring

One of the first toys I had as a child was a Slinky plastic coiled spring. I had a fixation with bouncing it from the top of the stairs all the way to the bottom. Springs have been an important technology in the industrial revolution; the coiled spring emerged in the 15th century and can since be found pretty much everywhere from cars to beds to pens. Non-coiled springs have existed since ancient times, and using the broad definition as a device that stores mechanical energy and can use elastic properties to convert it to kinetic energy, one could consider the first spring to be a bow.

The first mathematical model of a spring was devised by Robert Hooke in 1678. He proposed that the force of the spring was proportional to its displacement.

The equation for a Hookean spring is:

**F = - kx**

Using Newton's second law, we can re-write this expression as a second order ODE

**x'' = -k/m x**

The simulation is a visualization of this equation. I also added the ability to dampen, making it more akin to a real spring

# Single Pendulum

Like the spring, the pendulum has a fascinating history. By definition, a pendulum is a weight suspended from a pivot in a manner that it can swing freely. In history the pendulum has been used in a seismometer to locate earthquakes in China. Later it was used to keep time in a clock and measure the gravitational acceleration of the Earth. The simplicity of a pendulum allowed to be utilized by multiple ancient civilizations in order to create time-keeping devices.

Like the Hookean spring, the simple pendulum can be described as a * simple harmonic oscillator *, however this is only true for small angles. The equation for the motion of a pendulum is as follows:

**θ'' = − g⁄R sin θ**

This can be solved iteratively using the same methods as the oscillating spring.