Forums > Jitter

### Sorting all cells by values in one plane

May 09 2013 | 3:55 pm

Quick background on this idea – I’m building a lighting control system that uses a 5-plane matrix (A,R,G,B, lighting fixture index) to drive lighting fixtures using arbitrary 2D RGB info. The 2D ‘space’ is represented as the floorplan of a venue where the ceiling is sprinkled with about 300 RGB LED fixtures. I’m laying out the LED distribution on the floorplan by sparsely populating the 5th plane of my matrix with lighting fixture indices in the appropriate locations.

The idea is that the ARGB part of the matrix can be used to generate and visualize arbitrary color content and then to subsample that color information, formatting DMX messages to the lights using the addresses in the index plane.

THE ISSUE:
I underestimated the complexity of sorting the matrix based on the index plane values. I had thought I’d run some jit sort (like jit.bsort) on the index plane (sorting the ARGB info along with it), and then pull the bottom 300 or so cells from that sort (0 – number of fixtures-1) and use the ARGB info to generate DMX commands, all hopefully at a decent refresh rate.

jit.bsort sorts on only one axis at a time. My CS days were a while ago but I think I’d need to cascade some fairly significant number of jit.bsorts in order to get the result I’m looking for. Undesirable from a processor overhead standpoint.

I can make this happen without actually sorting the values – I really need only to select cells that have non-zero values in the index plane – but my iterative thinking doesn’t map well to the way jitter objects work.

Can anybody advise on a best way to approach this? Pseudocode-wise, I’m thinking:

1) Take a 5-plane matrix as input (resolution of original matrix is roughly 560 x 820)
2) Select cells that have non-zero value in the 5th (index) plane
3) Extract ARGB information from those cells, coupled with their index values
4) Make available those (300-ish) 5-value lists (per frame) at a reasonable rate (~40Hz)

Thanks for any help in advance!

May 10 2013 | 5:47 pm

if you don’t have to be exact (meaning you simply want the 300 or whatever highest index values), you can cascade two jit.bsorts and send the result to jit.submatrix. also check out the 3rd party xray externals for xray.jit.quicksort, which may be faster.

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

```
if you need to be exact, then you’re probably going to have to use jit.iter or jit.spill.
```
May 20 2013 | 2:03 pm

Hey thanks Rob! I think you’re right about that … the problem is simpler than I thought.

Thanks again!

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

Forums > Jitter