Imagine driving a car. When you travel at a certain velocity and then suddenly press the brake, you feel a force pulling you forward. Now, if you watch yourself hitting the brake from an inertia frame of reference (you might be standing a few meters away and watching), meaning that your reference frame is inertial and not accelerating, you will notice that that force is nothing but the car hitting you. However, describing from a non-inertial reference frame, where you are experiencing all of this in the driver's seat, you experience this force as a force. This type of force is called a fictitious force. Here is a quote from Wikipedia: "A fictitious force (also called a pseudo force, d'Alembert force, or inertial force) is a force that appears to act on a mass whose motion is described using a non-inertial frame of reference, such as an accelerating or rotating reference frame."
I will be investigating the motion of an object in a rotating reference frame. Rotating reference frames are ubiquitous - from ocean waves to the direction in which hurricanes spiral. These small particles in oceans or hurricanes, though under the influence of gravity, travel in straight trajectories. It is the rotation of the earth that gives us a non-inertial illusion that they are curving in a certain direction as if they are affected by certain forces. The names of these forces are called Coriolis, centrifugal, and Euler's force - these fictitious forces all exert forces in different directions and with changing magnitudes. Studying these fictitious forces is important because, oh well, we live on a sphere that rotates 1000 mph.
Below are two possible routes for my simulation. For the first route, I do it the traditional, bottom-top way. Say I set an initial velocity for the object. I then integrate that velocity with respect to time, take into account the effects of the fictitious forces, and calculate the position of the object. For the second route, I design the simulation in a rather top-down, kinda brute-forced manner. I rotate the frame in which the object is moving and then use image recognition libraries such as OpenCV to measure the position of the moving object, since obtaining coordinates of the object directly doesn't allow me to escape the inertial frame of reference.
Since the role of a simulation is to verify the theory, the first route might be redundant as it is built through theory.
The first example is built through the library p5.js. The library simply lets developers create 2D shapes faster. I created a class for my circular objects and wrote codes to detect whether the position of the object touches the circle(using the circle equation x^2+y^2 = r^2). The coordinate system built in the p5js library is slightly unintuitive, so I created some offsets in the class getters.
See the Pen XWjLqpE by steven oh (@stevenohohohohoh) on CodePen.
For this example, I actually used a 2D physics engine called matter.js. After doing some researches, I found out that physics engine is a overdo for my project. The engines are effective at processing collisions. Since my project probably doesn't involve collisions, using p5js like the example above is probably a wiser choice. Anyways, I created a custom render so I can rotate the frame. It is impossible to create a hollow circle in matters. However, a StackOverflow post suggested overlapping polygons to create such a shape. In addition, if you scroll to the bottom, you can see that I was playing around with screen recording and saving the video into a Blob object. I am not done with that part yet. Note: press rerun at the bottom right to rerun
See the Pen Rotating reference frame by stevenohohohoh (@stevenohohohoh) on CodePen.