All projects

Physics Simulator

3D Newtonian physics simulator built into sandbox environment. Rigid bodies drawn in separate CAD program.

Date
June 2019
Area
Mechanics
Skills
C#.NET
Physics Simulator

Ask about Physics Simulator

AI answers based only on the projects on this site. It can make mistakes, so check the linked project.

01Background

I was frustrated that I didn’t have the money to test hardware designs, so I built a physics environment as a sandbox to test mechanisms. I wrote the graphics and physics libraries myself so that I would have control over what I was simulating. There is a 3D drawing tool to complement the sandbox.

02Details

Graphics: After binge-watching a computer graphics lecture series from UC Davis, I wrote some linear algebra classes and implemented a quaternion trackball for 3D rotations. I then used a projection matrix in homogeneous space to represent perspective, based on how things appear smaller they move away. I then added polygon clipping and preferential rendering so that polygons in-front would be rendered last. Drawing Tool: I made a 3D isometric environment with a console to issue draw and select commands. This allowed me to draw 3D shapes which I would manually serialise and parse to save and load geometries between the sandboxes. I only allowed the drawing of triangles, points and lines, making this a very lightweight drawing tool. Physics: I made a physics clock event to handle physical quantities and collisions. I modelled every geometry as a rigid body of point masses for ease of inertia tensor calculation, and use Newton’s 2nd law to simulate kinematics.

03Outcome

The geometries rendered and collided in an expected manner, although there was some flickering in the overlapping polygons. I was going to add a feature for continuous collision (sliding) but I had to refocus on GCSEs.