Modulus

Modulus operator returns the r value (remainder) after dividing a with b

r = a % b

for example:

  • r = 7 % 5; r = 2;
  • r = 5 % 5; r = 0;

Use modulus to choose odd or even number

In this example, we got a polygon circle and we choose only points with odd numbers and push them out to turn a circle into a star shape.

if (@ptnum%2==1) {
    @P += @P*ch("amount");
}

Use modulus operator to cycle value

To cycle the value in Carve node, we can use:

experession in First U: fit(@Time%4,1,4,0,1)

experssion in Second U: fit(@Time%4,0.1,3.5,0,1)

Add a foreach loop to create the offset for carving.

Leave a Comment