In Modular arithmetic, we deal with a fixed quantity of integers, and whatever calculation(addition, subtraction, multiplication, division) we perform, our results are always within that fixed set of numbers.
An intuitive example would be the 12hr clock. If the present time is 9:00 then the time after 5hrs would be 3:00hr instead of 14:00hr. In this calculation we note that the value always lies inside 12 and here the numbers "wraps-around" after reaching the maximum set quantity(i.e 12 in this case). The maximum set quantity is called modulus. A clock would be example 12 modulus. We use the modular operator to find the value. In the above example, the answer is calculated by (5+9) modular 12, we get reminder 2 as the required value.
We will apply this concept to visualize beautiful modular multiplication on a circle for a higher number of modulus. This gives us some amazing patterns.
.
We take a circle and add number of equidistant points on it. The count of the total number points is the modulus. If we take 10 points on the circle the modulus will be 10. Each point denotes a number starting from zero. Basically, the number will be the index of the point.
Now we choose an integer multiplier. Let's start with multiplier 2. We multiply the index of each point and calculate the corresponding modular value. Eg 2*1=2, 2mod10 is 2. So join points 1 and 2 with a line.Similarly, all the points are mapped with its result.
With the help of GCScript, we can write a function in Line node to do this.
function (Point[] pt, int multiple) { Line ln; for (int i = 1; i < pt.Count; ++i) { ln = new Line(this); if (i!=i*multiple%pt.Count) { ln.ByPoints(pt[i],pt[i*multiple%pt.Count]); } } this.Color = Random(1,255); }
With slider, we can further change the multiplier and number of points(i.e the modulus) to get beautiful patterns. Some examples are illustrated in the below Video.
Please go through the sample file ModularMultiplicationOnCircle.gct