Using the Modulo node


The Modulo operation gives the remainder after division. For example, 14 modulo 12 gives you 2, because 12 goes into 14 once, with 2 left over.

You can use the Modulo node to generate a sequence of numbers that continually wraps around. For example, the sequence 0,1,2,0,1,2,0,1,2,… is the result of applying “modulo by 3” to the sequence 0,1,2,3,4,5,6,7,8,…

0 = 0 modulo by 3
1 = 1 modulo by 3
2 = 2 modulo by 3
0 = 3 modulo by 3
1 = 4 modulo by 3
2 = 5 modulo by 3
0 = 6 modulo by 3

In an ICE tree, you could use Modulo to sequentially assign instances from a group:

Modulo_InstanceShape1

You could also use Modulo to do something to every Nth particle. For example, in the “modulo by 3” sequence “0,1,2,0,1,2,0,1,2,…”, note that every third number is a “2”. So if you wanted to do something to every third particle, you would set up this ICE tree:

Modulo_Every3rd

Modulo arithmetic is sometimes called “clock arithmetic”. Consider that when you add 5 hours to 9am, you end up with 2pm, which is an example of modulo 12 arithmetic:

9:00 + 5 hours = 2:00
9 + 5 = 2
2 = 14 modulo by 12 (12 goes into 14 once, with 2 left over)

Here’s some visual displays of modular arithmetic.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s