Difference between revisions of "Modulo Scalar"
Line 1: | Line 1: | ||
− | |||
− | |||
− | |||
[[Image:drex_module_80_image_0.png|485pxpx|Modulo Scalar]] | [[Image:drex_module_80_image_0.png|485pxpx|Modulo Scalar]] | ||
Line 8: | Line 5: | ||
* '''Input 2: '''The value corresponding to Input 2 in the description above. | * '''Input 2: '''The value corresponding to Input 2 in the description above. | ||
− | |||
<!-- imported from file: module_80.html--> | <!-- imported from file: module_80.html--> | ||
+ | |||
+ | [[Category:Divide| ]] |
Revision as of 01:14, 18 May 2011
Node Description & Purpose:
The Modulo scalar node is a function which does modulo division, also known as remainder division. The calculation it does is very simple and looks like this :
Input modulo Input 2
The output is the remainder of Input divided by Input 2. For example :
5 modulo 4 = 1
because the remainder of 5 divided by 4 is 1. As another example :
5 modulo 5 = 0
because 5 divided by 5 has no remainder. Similarly :
6 modulo 3 = 0
because 6 divided by 3 has no remainder.
One of the situations that modulo division is most useful in is for making repeating patterns. Imagine that you wanted to divide the X axis into blocks 5 units long. You would set up a Modulo scalar node so that the Input was the X position and Input 2 was a Constant scalar node with a value of 5. This will output values which look like this :
X value: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Output : 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0
As you can see you now get a repeating series of numbers from the output. Note that for this to work you need to make the Input value the varying number (in this case the X axis position) and the Input 2 value the constant value you are comparing with (5 in this case). If you did it the other way around you would get a output like this :
X value: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Output : 0 0 1 2 1 0 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
As you can see this does not give the same repeating sequence of numbers.
Let's go back to the original example. Imagine you wanted to make every place you get a zero from output as a white dot, and every place you got a number greater than zero as a black dot. You could make a pattern like this (where "o" is a white dot and "m" is a black dot) :
X value: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Output : 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0
Pattern: o m m m m o m m m m o m m m m o m m m m o
That is a pretty simplistic example, but hopefully you see what is meant. Using modulo division is the basis for creating repeating patterns.
Node Type: Function
Settings:
- Input 2: The value corresponding to Input 2 in the description above.
A scalar is a single number. 1, 200.45, -45, -0.2 are all examples of scalar values.