Accumulating points?

Raconteur's picture

Hi all,

I am getting there with this comp I am working on. But I am still seeing things that defy my understanding, or fly in the face of it (as is usually the case).

I have a comp that I want to specify a number of iterations over. I publish the iterations var of an Iterator so I can set them in the Viewer. No problem.

Inside the iterator, I want to draw a point for each iteration, at a position that I calculate on each iteration.

My iterator has a Random in it to generate random X and Y values to plot the points.

What I have seems like it should work, but it doesn't the dots just dance around the screen and do not remain where they were drawn.

I am not sure if I have a fundamental misunderstanding, or if I am not doing something I should be.

I can post the comp if it will help, but was hoping to get this thing sorted out and post my first working QC app.

Can anyone help based on that info?

Cheers,

Chris

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

jersmi's picture
Re: Accumulating points?

Well, I would like to see the comp, just cuz I'm curious. :)

Try making the random patch time external, then manipulating it with some math combining it with current index. Check out the "Random Nested Iterator" (in the folder Developer>Library>Quartz Composer>Examples>Patches) -- that comp explains how externalizing patch time turns the random patch into a LUT.

Probably nothing like what you are up to, but here's a comp. If I could do javascript at all this would probably be a good opportunity... and btw there is some unresolved math in this comp, or i haven't fixed the point colors duplicated around the edges, maybe all indices are showing slightly "unregistered", not sure...

PreviewAttachmentSize
rdm_Yt.qtz17.18 KB

DanieleCiabba's picture
Re: Accumulating points?

try using the Image Accumulator - Paint.qtz example composition

PreviewAttachmentSize
Image Accumulator - Paint.qtz7.57 KB

cybero's picture
Re: Accumulating points?

The thing is both uploads above do cover the bases you mentioned after one fashion or another, although Image Accumulator - Paint actually accumulates and doesn't strictly iterate :-).

Find attached a composition that strictly sticks to iteration positions, as well as showing how the same sort of objects can be iterated dynamically.

PreviewAttachmentSize
IterationsStuck.qtz7.27 KB

gtoledo3's picture
Re: Accumulating points?

It sounds like your problem, conceptually, is that your random patches are inside the iterator.

My impression from reading your post, is that what you need to be doing, is taking your random points, and turning them into a structure, or simply recording them in some way... you can achieve that by using the queue patch, or a javascript queue. Then, you're building a structure list, which is what actually gets iterated...

I haven't looked at the posted examples yet...but I think this is sort of a textbook example in some ways. So, if you want all of the randoms to "freeze" just disconnect that lfo, and leave the queues in non-fill mode.

On another note, you may want to investigate the Kineme structure maker as a way of creating structures. With something like that, it's really easy to make a "table" of x/y/(z) values (or rotations, sizes...whatever), and then iterate to make each render patch live in a different place.

PreviewAttachmentSize
Iterator Freezeframe.qtz11.27 KB

Raconteur's picture
Re: Accumulating points?

Hey George,

Thanks for chiming in, and thanks everyone else for the input.

It sounds like you (George) might be saying that the underlying concept with this sort of thing is to iterate to generate the values, and then perform a second iteration over those values to plot the points. Is that correct?

Does that mean the each frame is going to iterate over the specified number of times, twice? Is that how the iterator works (each frame kicks off the entire iteration)?

Cheers,

Chris

Raconteur's picture
Re: Accumulating points?

Hi Cybero!

Thanks for this. This is exactly what I was looking for (I think...). But, I am not getting something in it...

With patches such as the LFO or Iterator, how do they render per frame? Does each frame render on iteration, or all of them? With the LFO, how do the period parameter and the frame relate?

I think this is (one of) my fundamental ignorances with QC. That and the fact that it is very EE-centric and I am, of all things, certainly NOT an EE!

Thank you all for the help. This place rocks. My hope is to become facile with QC (this makes my 19th computer language, if you call it that) enough to contribute as consistently and accurately as the key players on Kineme.

Thanks for helping my journey to that goal. I truly appreciate it.

Cheers,

Chris

gtoledo3's picture
Re: Accumulating points?

Raconteur wrote:
Hey George,

Thanks for chiming in, and thanks everyone else for the input.

It sounds like you (George) might be saying that the underlying concept with this sort of thing is to iterate to generate the values, and then perform a second iteration over those values to plot the points. Is that correct?

Does that mean the each frame is going to iterate over the specified number of times, twice? Is that how the iterator works (each frame kicks off the entire iteration)?

Cheers,

Chris

It sounded to me that what you ultimately wanted to achieve was sets of objects at random positions on x/y.

What I was suggesting (and the previously attached qtz demontrates) wasn't using an iterator to generate values, but random patches (or anything...lfo's, mouse movement, whatever), and then recording those values into a queue, which turns it into a structure. Then, by using an iterator, one can use the structure patches to sort through the random positions recorded by the queue, and place each of the objects at the appropriate random position.

Now, if you just want to use a random patch inside of an iterator and not have stuff dance around, take the random patch, control+left click on it, and set the time base to external. Then, connect the timebase to the current position of an iterator variable patch. I don't know how random of a look that produces though, which is why I suggested the other method, which allows you to have many different random looks.

Raconteur's picture
Re: Accumulating points?

Ack... ok, I am confusing myself now. I was sure I looked at the Iterator Freezeframe comp, and it was different than what I am seeing now. I must have clicked a different patch in my downloads directory.

At any rate, my comment was based on the IterationsStuck comp you put up.

It seems that the IteratorVariables is the key to getting things to stick around. I was not using them at all before because I just needed a number of points to plot.

Let me describe my algorithm and maybe that will help my understanding more, and give you some insight on what I am missing.

1) Click on the screen to select a starting point. 2) Take a random point (calculated) and plot a point 1/2 way between the starting point and the random point. 3) Using the point plotted in step 2 as the starting point, repeat step 2, times the number of iterations.

Here is the comp... it is a bit mucked up from the last bits of tinkering, but you can see where I am using Sample and Holds to retain values.

I think the thing I am not understanding is how the iterator works from frame to frame. Does it iterate completely on every frame? I am assuming it must.

Thanks!

Chris

PreviewAttachmentSize
ChaosGame.qtz15.73 KB

Raconteur's picture
Re: Accumulating points?

I got it. Was having the same problem with the points not sticking around until I noticed that the Queue could have its length set directly. Attached the Queue length to the number of iterations, and viola!

Will post in a separate thread. Would love to hear comments, optimizations, enhancements.

Thanks all for the help!

cybero's picture
Re: Accumulating points?

Iterator Variables + or [*] Math [Expression] = success :-)