We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Creating a matrix of lines in this syntax
Page Index Toggle Pages: 1
Creating a matrix of lines in this syntax (Read 602 times)
Creating a matrix of lines in this syntax
May 9th, 2010, 7:31pm
 
Hello im trying to create a matrix of lines with this way:
Im using glmodel , and it just uses one  array to define all the lines or points, for example:
if i have coords[43, 14, 0 , 0 , 24, 44, 0, 0, 42, 33, 0 ,0 52, 23, 0 , 0]
the first value is x , the second one is y, third one is z , fourth one is alpha, the 5th one is x of my second point, sixth is y of my second point and so on.
So if i would like to draw 2 lines that array would mean:

line (43, 14 , 24, 44 )
line2 (43, 33, 53, 23)


Im trying to create an array of lines , ive made the following code:

Code:

float y = 0;
for(int j = 1; j < 6 ; j += 1){
float x = 0;
for(int i = 0; i < 8 * 6 ; i += 8){
coords[i * j ] = x; //x1
coords[i * j + 1 ] = y + 0.2 ; //y1
coords[i * j + 4 ] = x ; //x2
coords[i * j + 5 ] = y + 0.35 ; //y2
x += 0.15;
}
y = y + 0.5;
}





but im getting this:

http://yfrog.com/0smatrizmalp


i would like to get this:

http://yfrog.com/86matrizbienj

anybody have an idea of what im doing wrong?

thanks

Seb.
Re: Creating a matrix of lines in this syntax
Reply #1 - May 9th, 2010, 10:00pm
 
You have to make only one loop, the i * j looks suspicious, use only one index with a step of 6.
Page Index Toggle Pages: 1