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 & HelpPrograms › Random lines from one circle to another
Page Index Toggle Pages: 1
Random lines from one circle to another (Read 2532 times)
Random lines from one circle to another
Sep 24th, 2009, 6:25am
 
Hi, this is my first post here, and also a question regarding my first processing project.
I've been reading the book by casey reas and ben fry, and doing some of the early stuff in there and am now making my first project.

What i want to achieve is basically 2 circles (where the lines come from, they dont have to be visible) with lines going randomly from circle one to number two.
The lines should have some sort of thicknes and also random jittery behaviour.
This will all happen in 3d
Offcourse i will now consult the book and probably come up with something, but i was wondering if anything like this has been done so i could take a look at the sketch?

And, i also want to have camera control with a joystick, turning right turns the whole 3d scene left, so you're viewing it from the right. And when you let go of the joystick the view turns back. Like a helicopter flight sim, but then controlling the camera. Is this sort of stuff even doable?

Thanks for every advice you can give me, greeting thomas

from rotterdam  Cheesy
Re: Random lines from one circle to another
Reply #1 - Sep 25th, 2009, 1:39am
 
oke i'm gonna need some help on this, if anyone has anything please let me know
Re: Random lines from one circle to another
Reply #2 - Sep 25th, 2009, 3:02am
 
Ok, i am not sure if i really understand what you want to do.
circles but not visible? then you probably dont need them. Its just coordinates you use to draw a line from and to. if you want to, you can draw circles at the endpoints but dont need to... but lets stay with the circles, spheres if 3d?  do you want a lot of them and a random line that connects only 2. or do you want 2 spheres that moves randomly and are connected by a line?

you can make some first tries, if you simply make some variables for an end and start point and add some random to it. then you get a jittery moving line between 2 points. add a third dimension then.

for the 3d camera, first start using http://mrfeinberg.com/peasycam/
its pretty handy. i would start thinking about joystick control later...

Re: Random lines from one circle to another
Reply #3 - Sep 25th, 2009, 3:56am
 
yeah its a pretty vague explenation of the project lol,

i want 2 planes, with lines racing from one to the other, lots of them, randomly starting somehwhere on plane 1 and going to a random point on plane 2 (wich will be far away in 3d)

i've somewhat created something like this, ill post the code below, although i have now idea how i would rotate the whole scene but maybe the link you posted will help. The main thing i'm trying to do now is to get the lines to fade away, so the screen doesnt get cluttered

thanks for the help

edit. got the camera working, the lines stay burned into 2d space though, let me post the code

import peasy.*;

PeasyCam cam;

void setup() {
 size(768, 576, P3D);
 cam = new PeasyCam(this, 100);
 background(0);
}

void draw() {
 strokeWeight(1);
 stroke(random(255), random(255), random(255), 100);
 line(random(768), random(576), 500, 0, 0, 0);
}

//camera beweegt om scene maar lijnen blijven staan, dus aparte camera void ofzo
//lijnen moeten snelheid hebben en weer vervagen
Re: Random lines from one circle to another
Reply #4 - Sep 25th, 2009, 4:06am
 
Thomas de Rijk wrote on Sep 25th, 2009, 3:56am:
getting this, but the peasycam folder is in my libraries install folder, and i also made a sketchbook folder with all my libraries pasted in it as well. And its still not getting the cam

Can you describe more precisely what are the paths you have set/you are using
Re: Random lines from one circle to another
Reply #5 - Sep 25th, 2009, 4:10am
 
got the camera working, i didnt include the line

PeasyCam cam;
Re: Random lines from one circle to another
Reply #6 - Sep 25th, 2009, 5:54am
 
can i ease the speed of a line?

i have something so far, but i want the lines to have random speeds, so i want to ease them (using float, i dont really understand how) and then give that a random number
and if someone can help me set up the sketch so that the lines won't stay on their place in 2d space when i turn the camera that would be nice, they're begin drawn in 3d, so why wont they just move with the camera?

halp

import peasy.*;

PeasyCam cam;

float x;
float y;
float z;
float targetX, targetY, targetZ;
float easing = random(1);

void setup() {
 size(768, 576, P3D);
 cam = new PeasyCam(this, 100);
 smooth();
}

void draw() {
 strokeWeight(1);
 stroke(random(255), random(255), random(255), 100);
 line(random(768), random(576), 0, random(768), random(576), 99999999);
 
}

//camera beweegt om scene maar lijnen blijven staan, dus aparte camera void ofzo
//lijnen moeten snelheid hebben en weer vervagen
Re: Random lines from one circle to another
Reply #7 - Sep 25th, 2009, 6:58am
 
i guess i dont understand again how the line should behave

but about your other problem. add background(255);
to draw,  so you wont see the last drawn lines.
Re: Random lines from one circle to another
Reply #8 - Sep 25th, 2009, 8:49am
 
they behave like the should now,

just going from 1 point to anothe really, and i found out about the background thing.

Now for the final point, when the lines appear now they are instantly on the other side,

i want them to grow, and have random speeds

i've been checking float and distances etc from the book, but that doesnt seem to work with lines

How can i make the lines grow with random speed? (and keep them in the screen when the next ones start to grow

So that it will be a race of growing lines and eventually a constant stream of growing lines going from plane a to b.
Re: Random lines from one circle to another
Reply #9 - Sep 25th, 2009, 12:54pm
 
Memorize two dimensions for each drawn line, and make the third one to grow. It should grow a bit on each draw() call.
Re: Random lines from one circle to another
Reply #10 - Sep 27th, 2009, 6:51am
 
oke, ill look into that, thanks

And the camera thing, it bet it has to do with that as well? (the way draw renews itself, or in this case, not renews itself)
Re: Random lines from one circle to another
Reply #11 - Oct 13th, 2009, 10:58am
 
oke hi im back again, i looked into the storin and stuff, but i'm getting hugely confused

SOOO could someone help me out or even write a quick program wich draws a line from coordinate a to b with a speed control? (line should grow over time)

that would be totally awesome



here's what i have so far, and i know i should make the line into an object, still have to do that, been trying to do this in max msp and quartz composer as well

import peasy.*;

PeasyCam cam;

float beginX = random(-400, 400);
float beginY = random(-300, 300);
float beginZ = -5000;
float endX = random(-400, 400);
float endY = random(-300, 300);
float endZ = 5000;
float distX = 0.0;
float distY = 0.0;
float distZ = 0.0;
float z = 0.0;
float step = 0.02;
float pct = 0.0;

void setup() {
 size(768, 576, P3D);
 cam = new PeasyCam(this, 100);
 smooth();
 distZ = endZ - beginZ;
 frameRate(120);
}

void draw() {
 background(0);
 pct += step;
 if (pct < 1.0) {
   z = beginZ + (pct * distZ);
 }


stroke(random(255), random(255), random(255), 100);
strokeWeight(2);
line(random(-800, 800), random(-800, 800), -8000, random(0), random(0), 8000);
line(random(-800, 800), random(-800, 800), -8000, random(0), random(0), 8000);
line(random(-800, 800), random(-800, 800), -8000, random(0), random(0), 8000);
line(random(-800, 800), random(-800, 800), -8000, random(0), random(0), 8000);
line(random(-800, 800), random(-800, 800), -8000, random(0), random(0), 8000);
line(random(-800, 800), random(-800, 800), -8000, random(0), random(0), 8000);
line(random(-800, 800), random(-800, 800), -8000, random(0), random(0), 8000);
line(random(-800, 800), random(-800, 800), -8000, random(0), random(0), 8000);
line(random(-800, 800), random(-800, 800), -8000, random(0), random(0), 8000);
line(random(-800, 800), random(-800, 800), -8000, random(0), random(0), 8000);
line(random(-800, 800), random(-800, 800), -8000, random(0), random(0), 8000);
line(random(-800, 800), random(-800, 800), -8000, random(0), random(0), 8000);
line(random(-800, 800), random(-800, 800), -8000, random(0), random(0), 8000);
line(random(-800, 800), random(-800, 800), -8000, random(0), random(0), 8000);
line(random(-800, 800), random(-800, 800), -8000, random(0), random(0), 8000);
line(random(-800, 800), random(-800, 800), -8000, random(0), random(0), 8000);

}

Page Index Toggle Pages: 1