Use Discretizator to make float or integer values more discrete, reducing a wide range of values to a more manageable subset at the cost of a certain amount of accuracy. This helps in potential optimization of the input data for the Shape Control suboperator but can be used for other purposes as well.
The discretization is based on two values: Base and Step. For each incoming value, the Step value is multiplied by an positive or negative integer and then added to the Base value in order to bring the result as close as possible to the input; the input is then rounded to this value. With Base "b" and Step "s," the possible output values from the suboperator are b, b+s, b–s, b+2s, b–2s, b+3s, b–3s, and so on.
The incoming values are rounded to the closest discrete value. If incoming value is exactly between the discrete values, it's rounded up to the next-highest value. For example, with Base 0 and Step 1, the input value 1.5 is output as 2, and input value –1.5 becomes –1.
You can find an example of Discretizator usage in the included file GridAndShapeControl.max. The flow contains more than 10,000 particles and incorporates two Data operators, both disabled at the beginning.
The first Data Operator does not use Discretizator; turn it on and note how long it takes to calculates the geometry shapes for all particles. It’s pretty slow, even on a fast PC.
Next, turn off the first Data operator and turn on the second one. It uses Discretizator in the data flow, and it works much faster when generating particle shapes. This is because the operator makes the incoming data stream discrete with the step of 1 degree. In the first case, the shape is calculated individually for each particle. In the second case the set of possible values is significantly reduced because values are snapped to whole degrees. Because Discrete Optimization is on in the Shape Control suboperator in the second Data Operator, the shapes are generated for 360 particles at most; this is the greatest possible number of different angle values with the step of 1 degree, and then these shapes are shared between particles. The eye cannot distinguish between these two cases, but the second one works much faster.
Thus, the Discretizator suboperator is a useful optimization tool for the Shape Control suboperator.