Forums > Gen

Getting a distance matrix to output "labeled" distance values

Feb 11 2013 | 10:10 pm

Hello everybody,

I’m building a patch in which I need to compute the distance between a tracked object and several fixed objects, so I thought that using a matrix and jit.gen to perform operations could be the most efficient way to make it.

Here’s what I got so far:

-- Pasted Max Patch, click to expand. --

The patch is working pretty well. What I need to implement now is formatting the jit.gen output this way: " ".
I think I can achieve this using jit.iter and a counter prepending the object’s number, but I wonder if there is a way inside jit.gen to do that: since every distance value lies on a different row of the matrix, is there some way (swiz?) to get the jit.gen object to output something like: " , , etc."?

Feb 11 2013 | 10:32 pm

send in a 4 plane matrix, and use the cell object to get the current row (if i’m understanding you):

-- Pasted Max Patch, click to expand. --

Feb 11 2013 | 10:54 pm

That’s it! Thank you, Rob!

Feb 12 2013 | 9:19 pm

I made a little correction in my jit.gen, as I noticed that the [param coords] was reading just the first number in the list.
Here’s the correct code:

-- Pasted Max Patch, click to expand. --

Feb 12 2013 | 9:58 pm

I was wondering how I could calculate distances within many objects in a time.
Imagine I have a group of moving objects in the left matrix and a group of static objects in right matrix and I want to estimate the distance between every moving object and every single static object.

-- Pasted Max Patch, click to expand. --

Could this a good start? (obviously it’s not working…)

For the moment, I think I’ll encapsulate the previous patch and use many instances of the same patcher.
Like this:

-- Pasted Max Patch, click to expand. --

Viewing 5 posts - 1 through 5 (of 5 total)

Forums > Gen