JFASI
11th November 2005 17:02 UTC
where am i going wrong???
Ok, so I got a problem. Something i'm making involves creating random quadrilaterals.
Here's my scope code:
Init
n=5
Frame
nr=0
Beat
cx1=rand(100)/100-.5;
cx2=rand(100)/100-.5;
cx3=rand(100)/100-.5;
cx4=rand(100)/100-.5;
cy1=rand(100)/100-.5;
cy2=rand(100)/100-.5;
cy3=rand(100)/100-.5;
cy4=rand(100)/100-.5;
Point
nr=nr+1;
x1=if(equals(nr,1),cx1,x1);
x1=if(equals(nr,2),cx2,x1);
x1=if(equals(nr,3),cx3,x1);
x1=if(equals(nr,4),cx4,x1);
y1=if(equals(nr,1),cy1,y1);
y1=if(equals(nr,2),cy2,y1);
y1=if(equals(nr,3),cy3,y1);
y1=if(equals(nr,4),cy4,y1);
x=x1;y=y1
no matter what I do, it flops. This isn't a one shot problem. I'm probably doing something conceptually wrong, but I can't find it.
Tuggummi
11th November 2005 18:48 UTC
*ahem* "equals"?
eheiney
11th November 2005 18:50 UTC
I'll give you one little hint. equals() is not a function. ;)
JFASI
11th November 2005 19:17 UTC
Ooooooops.
:confused: The one thing I didn't check, either :confused:
Thanks
Now how can I extend this to more than 4 points...
Is there anything in the syntax that would mean:
cx(nr)
?
Hmmmm. I could take the code out of the Beat, and use the b variable...
UIUC85
11th November 2005 23:00 UTC
Theres no way to make new arrays like what you're describing. However if you look at the help you do have megabuf() and loop() at your command. So you could try something like...
init:
n=8;
frame:
nr=0;
beat:
loop(2*n,exec2(assign(nr,nr+1),assign(megabuf(nr),rand(100)/100-.5)));
assign(megabuf(n),megabuf(1));
assign(megabuf(n+1),megabuf(2*n));
point:
nr=nr+1;
x=megabuf(nr);
y=megabuf(nr+n);
Now you can change n to whatever you want and get a random shape with n-1 sides!
JFASI
14th November 2005 03:01 UTC
Ah... I think I get loop better. Does it force the section to be repeated for whatever amount of time you make it? That would make things easier for me...
UIUC85
14th November 2005 04:59 UTC
yeah it'll execute the statement it is paired with that many times or in this case 2*n. Since there's n x values and n y values then you need 2*n values and to close off the shape you have the last and first values of x's and y's be the same which is why the statements below it are there.