Associative modelling 1
Symbolic expressions to epicycles
Last updated
Symbolic expressions to epicycles
Last updated
The objective of this session is to introduce the process of modeling by establishing associations among components. We will extend the concepts of ranges, expressions and transformations using the visual programming paradigm. This will allow us to overcome several limitations of using spreadsheets. By the end of this session you will be able to create designs using visual programming methodology.
The animation below illustrates the steps for recreating an integer range using the “series” component. It is the equivalent of the “index” range used in the spreadsheet environment. The significance of the integer range is in that it represents the concept of an iteration over a finite number of steps. When python is introduced the same concept will be expressed as the “for-in-range” construct.
The “series” component requires three inputs, namely the initial value “start”, the increment amount “step” and the number of iterations “count”. The component is automatically supplied with default input parameter values, seen in the diagram below, if no wires are connected to its inputs. Parameters that we do not have to necessarily provide with input values are also known as as “optional” parameters.
The animation below illustrates the effects of using non-default values for the “start” and “step” parameters. The important aspect of this component is that it outputs not one but multiple values. This is highlighted by the output wire being a thicker double line versus the slider’s wire being a single line i.e. representing one value.
The “panel” component assists in visualizing a sequence’s items order by including a header column; not unlike the one seen in spreadsheets. It indexes generated items in the [0, Count-1]
range i.e. it starts counting from zero instead of one.
We may also visualize the range generated by the “series” component by associating its output with the “x” coordinate of a point. We can then interactively display a series of points in the viewport.
The “construct point” component creates three dimensional points defined by their “x”, “y” and “z” coordinates. We may supply one or multiple values for any or all of the coordinate inputs, producing a single point or a sequence of points.
You may have noticed we have already overcome some of the limitations of working with spreadsheets. By just using the “slider” and “series” components we can easily expand the range to any number of iterations. In addition, the process of generating and visualizing data is instantaneous. We do not have to transform expressions to commands and copy / paste them. Overall the modelling process feels more direct and intuitive.
Practice
Create sequences of points that span both positive as well as negative values using the “series” component’s “start” and “step” parameters.
Experiment with supplying a “series” component’s output to the input of multiple point coordinates. How can you explain the behaviour?
Try creating multiple “series” components with different “start”, “step” and “count” parameters and connect them to point coordinates. What is the result?
Next we recreate the function graphing logic, developed in the last session. The objective is to demonstrate basic arithmetic operations performed via visual programming components.
The construction creates the equivalent of the “time” range in spreadsheets using the notion of range normalization. The points drawn in the viewport are now bounded in the unit line. Next we construct points of a sine wave by transforming the time range into angle, by scaling it into [0, 2π]
, and finally connect the angle and sine values to the point’s coordinates.
Notice that we do not need to navigate the palettes to find components but instead double click in the graph canvas and start typing the desired component’s name. The search box auto-completes the entry by suggesting various available options.
We complete this section by reproducing points of a regular polygon or equivalently points on the unit circle. All we need to perform is to apply the parametric formula of circle [ x, y ] = [ cos( a ), sin( a ) ]
, where a
is the angle in the range [0, 2π]
.
Components such as basic arithmetic e.g. addition, subtraction, multiplication and division are pretty straightforward. Moreover, trigonometric functions such as the sine and cosine require also little explanation; they map to familiar concepts from pre-university mathematics courses.
What does require a moment to consider more carefully however is the ability to automatically perform operations to multiple values using a single component. For example we multiplied the entire range of numbers in [0, 1]
by 2π
to produce a new range mapped into [0, 2π]
. This ability alone is quire remarkable because it automates significant amount of work, eliminates concerns about whether we need to design logic around one or multiple values and compacts the visual representation of the graph reducing visual clutter.
Practice
Use basic arithmetic operations to allow translating the sine wave horizontally and vertically using two offset parameters expressed as sliders.
Update the graph to incorporate a parameter that captures the notion of the radius of the circle produced.
Develop a graph that allows us to create a subset of the sine curve instead of the entire [0, 2π]
range.