Archive

Archive for April, 2011

Studies on light and motion

Take light, make a photo, then break it. Just stay there, watching…

take light…

light motion

take light…

point wave

Categories: code, openGL

setcell vs copyArrayToVectorPlanar method

Java/jitter offers two different ways to ‘fill up’ matrices: setcell and copyArrayToVectorPlanar. So far I find the second cleaner and more efficient. However, the criteria for their use might be related with the context of use. Herewith a small example of how to use setcell in order to create a random jitter matrix:


import com.cycling74.max.*;
import com.cycling74.jitter.*;
import java.util.Random;

public class SetMe extends MaxObject{
Random rrand;
JitterMatrix jl;
static final int PLANES=3;

public SetMe(){
//super();
//declareIO(1,2);
jl=new JitterMatrix(“hehe”,PLANES,”float32″,10,10);
this.rrand=new Random();
}

public void bang(){
this.calculateMe();
outlet(0,”jit_matrix”,jl.getName());
}

public void calculateMe(){
for(int k=0;k<PLANES;k++){
for(int i=0;i<10;i++){
for(int j=0;j<10;j++){
jl.setcell(new int[]{i,j},k,rrand.nextInt(10));
}
}
}
}
}

It is important to notice how copyArrayToVectorPlanar uses a single dimension loop to fill the matrix, whereas setcell requires two values to point the location of each one of the values. Maybe here is the bottleneck for this method?

Categories: jitter