April 2015
The terribly-named Simulator project was started to investigate a number of technologies. Primarily, I wanted to determine the difference between modern OpenGL and modern DirectX, so I wrote this application as a C++ DirectX Windows Modern Application. Secondarily, I had previously programmed an electromagnetic simulator that did not take into account the speed of light, so I wanted to attempt creating a more realistic small-scale electromagnetic simulation. Finally, I was interested in seeing how creating a full-screen Windows Modern Application would be different than a desktop OpenGL / DirectX application.


To test all of these technologies, I decided to not simulate quantum mechanics and only simulate point particles.

With my previous simulator, I had used Lorentz's Force Law in combination with Newton's Second Law to simulate particle motion, and roughly approximate the electric and magnetic fields from the particle positions and velocities.
$$\vec{F}=q(\vec{E} + \vec{v}\times\vec{B})$$




However, these approximates above don't account for the time that it takes for changes in a particle's position to be visible to other particles, because information only travels at the speed of light. These approximate equations above are only correct for non-relativistic, steady-state situations.
For this simulation, I used a (less approximate) equation from my E&M course and stored the history of each particle's motion so that time effects could be properly considered. By setting \(\vec{u}=c\hat{R}-\vec{v}\), the following equations were used:


For the physicists out there I didn't add the Abraham-Lorentz force to these equations because -- as expected -- the particles spontaneously accelerates when done so.


Image in card

In terms of the software, this screenshot shows:
  • Geometry-shader generated arrows
  • The usage of both Direct2D and Direct3D to draw info text.
  • A fullscreen Windows Modern App

In terms of the simulation, this screenshot also shows the electromagnetic waves being propagated over time, as expected.

Surprisingly, I found programming in modern DirectX to be extremely similar to programming in modern OpenGL. In both cases, you load shaders, setup the data format for the shaders, load a vertex buffer with triangles, and batch render through the shaders. Even the shading languages (HLSL/GLSL) are very much C-like, with minor differences. Overall, if you know how to do vertex-array-based OpenGL or DirectX programming, you'll be able to transition into using the other language very, very quickly.
Site Copyright © Gustave Granroth, 2019.