Modelling entities 1
Projectile physics
Last updated
Projectile physics
Last updated
In this session we will develop the core process blocks for our physics engine. We will explore the notion of dimensionless bodies or particles, perform force analysis and motion state integration. The graph below captures the high-level composition of the simulation building blocks.
The key aspect to consider here is that while we will be using physics as our primary modelling interface, the desire is not necessarily to study physics. Physics is just a tool for modelling behaviours. We wish to create models that contain entities interacting with one another, each having its own agenda and desires and resolving constraints using the notion of minimizing effort and finding equilibrium. While initially we will be faithful to the law of physics, we will eventually start making our own laws.
The simulation is comprised of several regions including: ▊Setup Model: contains the definition of the model’s initial conditions; ▊Simulation Controller: manages data and time; ▊Visualization: displays various geometric and physical properties; ▊Physics Logic: which further break down to force analysis, state integration and constraint enforcement.
The simulation logic is based on dimensionless bodies also known as particles. When defining new computational entities we need to carefully decide what is the essential information related to the object we wish to describe. Particles at the most basic level require: Position: expressed as points in metric space units such as meters, Velocity: expressed as vectors in metric space per unit of time, such as meters per second; and Mass: expressed as scalars in mass units eg. kilograms. Those properties is what we wish to capture over time. We call this group of properties the particle’s state.
From a technical perspective there is nothing complicated taking place here. We just create three positions, three velocities and three masses and package them in lists using the “merge” component. Those define the particle’s states which we package with a special cluster component.
Earlier we discusses serialization for building a ticking clock. We need to expand those concepts as we wish to propagate the particle’s states instead of a simple integer across time. The goal is to pack particle’s properties into text and later on unpack them back into positions, velocities and masses.
Packing complex data into text requires establishing conventions such that we can perform conversion unambiguously and fast. We already encountered the case of spreadsheets coping data into the clipboard using the “tab” as column delimiter and “new line” as row separator; as well as the CAD application’s command line interface using “,” as point coordinate delimiter and ” ” as instruction separator.
The graph below replicates the same concept: we pack particle states by first building a table of numeric values from the position coordinates, velocity components and masses; and then convert into text by inserting special characters between the text representation of those numbers, to denote column and row separation.
We use entwine and transpose such that each row of the table contains one particle. The seven columns (3x position + 3x velocity + 1x mass) are concatenated using the “join” component with a comma “,” as delimiter. Rows are then fused using the semi-colon “;” as separator. The figure below shows the interim values produced.
Below are some examples of concatenating multiple fragments of text using various delimiters between entries.
Unpacking represents the symmetric opposite of packing. We expect a text value and we decompose it into parts which are converted to numbers and then into complex data types such as points and vectors. The process of splitting a text string is also known as parsing and the fragments produced as tokens.
We use the “text split” component to reverse the operation of “text join”. The process is performed in reverse i.e. first we break the text into rows using the semi-colon “;” separator and then into columns using the comma “,” delimiter. To assemble the data we use the “list item” component and the requisite point and vector constructors.
Practice
The model setup defines three unit mass particles all positioned at [0, 0, 0] but with different initial velocities. While all particle velocities are in speed sense 15 m/s their angle from the horizontal varies between 30, 45 and 60 degrees. This simple scenario is inspired by the potato cannon 2D freshmore design assignment which started back in 2012 at the Dover SUTD campus [].
Experiment with packing and unpacking data using various delimiters. Note that the “new line” is captured using one or two characters including “carriage return” and “new line” [] so be careful.
Try to develop as serialization strategy such that you can import/export point data to and from spreadsheets using comma separated values [].