Modulus

   3051   2   0
User Avatar
Member
27 posts
Joined: March 2017
Offline
hey guys, sorry for this silly question but i got little bit confused and can anyone explain to me what does it mean? L`($F-1)%17 in “delete” node L(LOWRES groups). thank you
User Avatar
Member
1737 posts
Joined: May 2006
Offline
When you learned division in primary school you'd do remainders, eg

7 ÷ 3 = 2, remainder 1
5 ÷ 3 = 1, remainder 2

modulo is just the remainder part:

7%3=1
5%3=2

This is useful for setting up loops. Eg, if you calculate the remainder of dividing things by 4, counting from 1 to 10, you get this (swapping ÷ for / like you do in most computer languages) :

1/4=0, remainder 1
2/4=0, remainder 2
3/4=0, remainder 3
4/4=1, remainder 0
5/4=1, remainder 1
6/4=1, remainder 2
7/4=1, remainder 3
8/4=2, remainder 0
9/4=2, remainder 1
10/4=2, remainder 2
etc

Or used in a timing structure this works for floating point too, so you could do @Time%1, and the result is a timing counter that goes 0.0, 0.1, 0.2… 0.8, 0.9, 0.0, 0.1, 0.2 etc

In that example above its taking the current frame ($F), subtracting 1, then modulo by 17. The result is a set of numbers that constantly counts from 0 to 16, 0 to 16, 0 to 16… for the length of your timeline.

The minus 1 part there just determines what the first number is, so here it starts at 0 rather than 1 (assuming your framerange starts from 1).

-matt
Edited by mestela - Oct. 8, 2017 19:35:51
http://www.tokeru.com/cgwiki [www.tokeru.com]
https://www.patreon.com/mattestela [www.patreon.com]
User Avatar
Member
27 posts
Joined: March 2017
Offline
that was the best explanation I've ever seen in my life. Thank you so much, I appreciate that.
  • Quick Links